mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
28 lines
568 B
C++
28 lines
568 B
C++
#include "curve_view_cursor.h"
|
|
#include <assert.h>
|
|
#include <cmath>
|
|
|
|
namespace Shared {
|
|
|
|
CurveViewCursor::CurveViewCursor() : m_t(NAN), m_x(NAN), m_y(NAN) {}
|
|
|
|
void CurveViewCursor::moveTo(double t, double x, double y) {
|
|
assert(!std::isnan(t));
|
|
m_t = clipped(t, false);
|
|
m_x = clipped(x, true);
|
|
m_y = clipped(y, true);
|
|
}
|
|
|
|
double CurveViewCursor::clipped(double x, bool canBeInfinite) {
|
|
double maxValue = canBeInfinite ? INFINITY : k_maxFloat;
|
|
if (x > k_maxFloat) {
|
|
return maxValue;
|
|
}
|
|
if (x < -k_maxFloat) {
|
|
return -maxValue;
|
|
}
|
|
return x;
|
|
}
|
|
|
|
}
|