Files
Upsilon/apps/shared/curve_view_cursor.cpp
Émilie Feral f0a776a670 [apps] Operations in double when precision required
Change-Id: I7168a861a76178f0bf81841e9378f7399f67914a
2017-08-17 09:31:53 +02:00

33 lines
595 B
C++

#include "curve_view_cursor.h"
#include <math.h>
namespace Shared {
CurveViewCursor::CurveViewCursor() :
m_x(NAN),
m_y(NAN)
{
}
double CurveViewCursor::x() {
return m_x;
}
double CurveViewCursor::y() {
return m_y;
}
void CurveViewCursor::moveTo(double x, double y) {
m_x = clipped(x, false);
m_y = clipped(y, true);
}
double CurveViewCursor::clipped(double x, bool canBeInfinite) {
double maxValue = canBeInfinite ? INFINITY : k_maxFloat;
double clippedX = x > k_maxFloat ? maxValue : x;
clippedX = clippedX < - k_maxFloat ? -maxValue : clippedX;
return clippedX;
}
}