24#ifndef BEZIER_CURVES_H
25#define BEZIER_CURVES_H
30template <
typename T>
class ELLIPSE;
43 BEZIER_POLY(
const std::vector<VECTOR2I>& aControlPoints );
57 void GetPoly( std::vector<VECTOR2I>& aOutput,
int aMaxError = 10 );
58 void GetPoly( std::vector<VECTOR2D>& aOutput,
double aMaxError = 10.0 );
62 void getQuadPoly( std::vector<VECTOR2D>& aOutput,
double aMaxError );
63 void getCubicPoly( std::vector<VECTOR2D>& aOutput,
double aMaxError );
77 bool isFlat(
double aMaxError )
const;
93template <
typename NumericType>
116 const double t2 = aT * aT;
117 const double t3 = t2 * aT;
118 const double t_m1 = 1.0 - aT;
119 const double t_m1_2 = t_m1 * t_m1;
120 const double t_m1_3 = t_m1_2 * t_m1;
122 return ( t_m1_3 *
Start ) + ( 3.0 * aT * t_m1_2 *
C1 ) + ( 3.0 * t2 * t_m1 *
C2 )
void TransformEllipseToBeziers(const ELLIPSE< T > &aEllipse, std::vector< BEZIER< T > > &aBeziers)
Transforms an ellipse or elliptical arc into a set of quadratic Bezier curves that approximate it.
Bezier curves to polygon converter.
void recursiveSegmentation(std::vector< VECTOR2D > &aOutput, double aMaxError)
void getQuadPoly(std::vector< VECTOR2D > &aOutput, double aMaxError)
int numberOfInflectionPoints()
double thirdControlPointDeviation()
void cubicParabolicApprox(std::vector< VECTOR2D > &aOutput, double aMaxError)
double m_minSegLen
Control points.
void getCubicPoly(std::vector< VECTOR2D > &aOutput, double aMaxError)
void subdivide(double aT, BEZIER_POLY &aLeft, BEZIER_POLY &aRight)
bool isFlat(double aMaxError) const
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMaxError=10)
Convert a Bezier curve to a polygon.
int findInflectionPoints(double &aT1, double &aT2)
BEZIER_POLY(const std::vector< VECTOR2D > &aControlPoints)
std::vector< VECTOR2D > m_ctrlPts
Generic cubic Bezier representation.
VECTOR2< NumericType > Start
VECTOR2< NumericType > C1
VECTOR2< NumericType > C2
VECTOR2< NumericType > End
constexpr VECTOR2< NumericType > PointAt(double aT) const
Evaluate the Bezier curve at a given t value.
constexpr BEZIER(const VECTOR2< NumericType > &aStart, const VECTOR2< NumericType > &aC1, const VECTOR2< NumericType > &aC2, const VECTOR2< NumericType > &aEnd)
This class was created to handle importing ellipses from other file formats that support them nativel...