[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 { namespace Shared {
CurveViewCursor::CurveViewCursor() : CurveViewCursor::CurveViewCursor() : m_t(NAN), m_x(NAN), m_y(NAN) {}
m_x(NAN),
m_y(NAN)
{
}
void CurveViewCursor::moveTo(double x, double y) { void CurveViewCursor::moveTo(double t, double x, double y) {
m_x = clipped(x, false); m_t = clipped(t, false);
m_x = clipped(x, false); //TODO LEA ?
m_y = clipped(y, true); m_y = clipped(y, true);
} }
double CurveViewCursor::clipped(double x, bool canBeInfinite) { double CurveViewCursor::clipped(double x, bool canBeInfinite) {
double maxValue = canBeInfinite ? INFINITY : k_maxFloat; double maxValue = canBeInfinite ? INFINITY : k_maxFloat;
double clippedX = x > k_maxFloat ? maxValue : x; if (x > k_maxFloat) {
clippedX = clippedX < - k_maxFloat ? -maxValue : clippedX; return maxValue;
return clippedX; }
if (x < -k_maxFloat) {
return -maxValue;
}
return x;
} }
} }

View File

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