diff --git a/apps/regression/data.cpp b/apps/regression/data.cpp index e12a6b41d..7110f805e 100644 --- a/apps/regression/data.cpp +++ b/apps/regression/data.cpp @@ -107,6 +107,20 @@ int Data::selectedDotIndex() { return m_selectedDotIndex; } +void Data::setCursorPositionAtAbscissa(float abscissa) { + m_xCursorPosition = abscissa; + centerAxisAround(CurveViewWindow::Axis::X, m_xCursorPosition); + m_yCursorPosition = yValueForXValue(m_xCursorPosition); + centerAxisAround(CurveViewWindow::Axis::Y, m_yCursorPosition); +} + +void Data::setCursorPositionAtOrdinate(float ordinate) { + m_yCursorPosition = ordinate; + centerAxisAround(CurveViewWindow::Axis::Y, m_yCursorPosition); + m_xCursorPosition = xValueForYValue(m_yCursorPosition); + centerAxisAround(CurveViewWindow::Axis::X, m_xCursorPosition); +} + /* Window */ void Data::setDefault() { @@ -197,6 +211,10 @@ float Data::yValueForXValue(float x) { return slope()*x+yIntercept(); } +float Data::xValueForYValue(float y) { + return (y - yIntercept())/slope(); +} + float Data::correlationCoefficient() { return covariance()/(xStandardDeviation()*yStandardDeviation()); } diff --git a/apps/regression/data.h b/apps/regression/data.h index f8b4731d4..abf4546cd 100644 --- a/apps/regression/data.h +++ b/apps/regression/data.h @@ -27,6 +27,8 @@ public: /* The selectedDotIndex is -1 when no dot is selected, m_numberOfPairs when * the mean dot is selected and the dot index otherwise */ int selectedDotIndex(); + void setCursorPositionAtAbscissa(float abscissa); + void setCursorPositionAtOrdinate(float ordinate); // Window void setDefault(); @@ -47,6 +49,7 @@ public: float slope(); float yIntercept(); float yValueForXValue(float x); + float xValueForYValue(float y); float correlationCoefficient(); float squaredCorrelationCoefficient();