[apps/curve_view_cursor] t member

This commit is contained in:
Léa Saviot
2019-08-28 10:43:03 +02:00
parent 7ea7ecd3c2
commit a45af36bfe
2 changed files with 14 additions and 11 deletions

View File

@@ -3,22 +3,23 @@
namespace Shared {
CurveViewCursor::CurveViewCursor() :
m_x(NAN),
m_y(NAN)
{
}
CurveViewCursor::CurveViewCursor() : m_t(NAN), m_x(NAN), m_y(NAN) {}
void CurveViewCursor::moveTo(double x, double y) {
m_x = clipped(x, false);
void CurveViewCursor::moveTo(double t, double x, double y) {
m_t = clipped(t, false);
m_x = clipped(x, false); //TODO LEA ?
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;
if (x > k_maxFloat) {
return maxValue;
}
if (x < -k_maxFloat) {
return -maxValue;
}
return x;
}
}

View File

@@ -6,12 +6,14 @@ namespace Shared {
class CurveViewCursor {
public:
CurveViewCursor();
double t() const { return m_t; }
double x() const { return m_x; }
double y() const { return m_y; }
void moveTo(double x, double y);
void moveTo(double t, double x, double y);
private:
static double clipped(double f, bool canBeInfinite);
constexpr static double k_maxFloat = 1E+8;
double m_t;
double m_x;
double m_y;
};