19 #ifndef HERMITECURVE_H
20 #define HERMITECURVE_H
41 inline const float f1()
const {
return m_f1; }
42 inline const float f2()
const {
return m_f2; }
43 inline const float f3()
const {
return m_f3; }
44 inline const float f4()
const {
return m_f4; }
67 void setIntMax(
unsigned long max);
71 std::size_t size()
const;
75 void removeAt(std::size_t n);
78 const std::size_t
findX0(
int x)
const;
80 const uint8_t getY(uint8_t x)
const;
82 const T getY(T x)
const;
83 const float getY(
float x)
const;
84 const double getY(
double x)
const;
88 std::size_t m_ctrlPointLutSize;
90 QVector<QHermiteControlPoint> m_ctrlPoints;
91 std::size_t m_ctrlPointsSize;
97 float fnormalizeFactor;
98 double dnormalizeFactor;
106 template <
typename T>
107 const T HermiteCurve::getY(T x)
const {
108 if (m_ctrlPointsSize == 2) {
109 double slope = (double)(m_ctrlPoints[1].y() - m_ctrlPoints[0].y()) / (
double)(m_ctrlPoints[1].x() - m_ctrlPoints[0].x());
110 return ((x * dscaleFactor - m_ctrlPoints[0].x()) * slope + m_ctrlPoints[0].y()) * dnormalizeFactor;
113 double scaledX = dscaleFactor * x;
114 std::size_t x0pos =
findX0(scaledX);
118 double u = (double)(scaledX - x0.x()) / (
double)(x1.x() - x0.x());
122 return (u3 * x0.f1() + u2 * x0.f2() + u * x0.f3() + x0.f4()) * dnormalizeFactor;
126 #endif // HERMITECURVE_H