49 m_ctrlPts.reserve( aControlPoints.size() );
51 for(
const VECTOR2I& pt : aControlPoints )
61 std::vector<VECTOR2D> buffer;
62 GetPoly( buffer,
double( aMinSegLen ), aMaxSegCount );
64 aOutput.reserve( buffer.size() );
67 aOutput.emplace_back(
VECTOR2I( (
int) pt.x, (
int) pt.y ) );
77 double dt = 1.0 / aMaxSegCount;
88 for(
int ii = 1; ii < aMaxSegCount; ii++ )
92 double omt2 = omt * omt;
93 double omt3 = omt * omt2;
107 if( dist_sq > minSegLen_sq )
108 aOutput.push_back( vertex );
133 const int minBeziersPerCircle = 4;
136 const int numBeziers =
static_cast<int>(
137 std::ceil(
std::abs( arcAngle.
AsRadians() / ( 2 * M_PI / minBeziersPerCircle ) ) ) );
140 const double angleIncrement = arcAngle.
AsRadians() / numBeziers;
156 double theta = angleIncrement;
157 double k = ( 4. / 3. ) * std::tan( theta / 4 );
169 { std::cos( theta ) + k * std::sin( theta ),
170 std::sin( theta ) - k * std::cos( theta ) },
171 { std::cos( theta ), std::sin( theta ) } };
176 auto transformPoint =
190 aPoint += aEllipse.
Center;
195 for(
int i = 0; i < numBeziers; i++ )
198 transformPoint( first.
Start, i * angleIncrement ),
199 transformPoint( first.
C1, i * angleIncrement ),
200 transformPoint( first.
C2, i * angleIncrement ),
201 transformPoint( first.
End, i * angleIncrement )
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.
double m_minSegLen
Control points.
BEZIER_POLY(const VECTOR2I &aStart, const VECTOR2I &aCtrl1, const VECTOR2I &aCtrl2, const VECTOR2I &aEnd)
std::vector< VECTOR2D > m_ctrlPts
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
Generic cubic Bezier representation.
VECTOR2< NumericType > Start
VECTOR2< NumericType > C1
VECTOR2< NumericType > C2
VECTOR2< NumericType > End
This class was created to handle importing ellipses from other file formats that support them nativel...
VECTOR2< NumericType > Center
VECTOR2_TRAITS< double >::extended_type extended_type
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_0
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
VECTOR2< double > VECTOR2D