mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/curve_view_cursor] t member
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user