KiCad PCB EDA Suite
Loading...
Searching...
No Matches
BEZIER_POLY Class Reference

Bezier curves to polygon converter. More...

#include <bezier_curves.h>

Public Member Functions

 BEZIER_POLY (const VECTOR2I &aStart, const VECTOR2I &aCtrl1, const VECTOR2I &aCtrl2, const VECTOR2I &aEnd)
 
 BEZIER_POLY (const std::vector< VECTOR2I > &aControlPoints)
 
 BEZIER_POLY (const std::vector< VECTOR2D > &aControlPoints)
 
void GetPoly (std::vector< VECTOR2I > &aOutput, int aMaxError=10)
 Convert a Bezier curve to a polygon.
 
void GetPoly (std::vector< VECTOR2D > &aOutput, double aMaxError=10.0)
 

Private Member Functions

void getQuadPoly (std::vector< VECTOR2D > &aOutput, double aMaxError)
 
void getCubicPoly (std::vector< VECTOR2D > &aOutput, double aMaxError)
 
int findInflectionPoints (double &aT1, double &aT2)
 
int numberOfInflectionPoints ()
 
double thirdControlPointDeviation ()
 
void subdivide (double aT, BEZIER_POLY &aLeft, BEZIER_POLY &aRight)
 
void recursiveSegmentation (std::vector< VECTOR2D > &aOutput, double aMaxError)
 
void cubicParabolicApprox (std::vector< VECTOR2D > &aOutput, double aMaxError)
 
bool isNaN () const
 
bool isFlat (double aMaxError) const
 
VECTOR2D eval (double t)
 

Private Attributes

double m_minSegLen
 Control points.
 
std::vector< VECTOR2Dm_ctrlPts
 

Detailed Description

Bezier curves to polygon converter.

Only quadratic and cubic Bezier curves are handled

Definition at line 37 of file bezier_curves.h.

Constructor & Destructor Documentation

◆ BEZIER_POLY() [1/3]

BEZIER_POLY::BEZIER_POLY ( const VECTOR2I aStart,
const VECTOR2I aCtrl1,
const VECTOR2I aCtrl2,
const VECTOR2I aEnd 
)

Definition at line 88 of file bezier_curves.cpp.

References m_ctrlPts, and m_minSegLen.

◆ BEZIER_POLY() [2/3]

BEZIER_POLY::BEZIER_POLY ( const std::vector< VECTOR2I > &  aControlPoints)

Definition at line 100 of file bezier_curves.cpp.

References m_ctrlPts, and m_minSegLen.

◆ BEZIER_POLY() [3/3]

BEZIER_POLY::BEZIER_POLY ( const std::vector< VECTOR2D > &  aControlPoints)
inline

Definition at line 45 of file bezier_curves.h.

References m_minSegLen.

Member Function Documentation

◆ cubicParabolicApprox()

void BEZIER_POLY::cubicParabolicApprox ( std::vector< VECTOR2D > &  aOutput,
double  aMaxError 
)
private

◆ eval()

VECTOR2D BEZIER_POLY::eval ( double  t)
private

Definition at line 190 of file bezier_curves.cpp.

References m_ctrlPts.

Referenced by getQuadPoly(), and subdivide().

◆ findInflectionPoints()

int BEZIER_POLY::findInflectionPoints ( double &  aT1,
double &  aT2 
)
private

Definition at line 367 of file bezier_curves.cpp.

References BEZIER_DBG, and m_ctrlPts.

Referenced by getCubicPoly().

◆ getCubicPoly()

void BEZIER_POLY::getCubicPoly ( std::vector< VECTOR2D > &  aOutput,
double  aMaxError 
)
private

◆ GetPoly() [1/2]

void BEZIER_POLY::GetPoly ( std::vector< VECTOR2D > &  aOutput,
double  aMaxError = 10.0 
)

Definition at line 577 of file bezier_curves.cpp.

References BEZIER_DBG, getCubicPoly(), getQuadPoly(), and m_ctrlPts.

◆ GetPoly() [2/2]

void BEZIER_POLY::GetPoly ( std::vector< VECTOR2I > &  aOutput,
int  aMaxError = 10 
)

◆ getQuadPoly()

void BEZIER_POLY::getQuadPoly ( std::vector< VECTOR2D > &  aOutput,
double  aMaxError 
)
private

Definition at line 214 of file bezier_curves.cpp.

References std::abs(), approx_int(), approx_inv_int(), eval(), m_ctrlPts, scale, and v2.

Referenced by GetPoly().

◆ isFlat()

bool BEZIER_POLY::isFlat ( double  aMaxError) const
private

◆ isNaN()

bool BEZIER_POLY::isNaN ( ) const
private

Definition at line 111 of file bezier_curves.cpp.

References m_ctrlPts.

Referenced by cubicParabolicApprox().

◆ numberOfInflectionPoints()

int BEZIER_POLY::numberOfInflectionPoints ( )
private

Definition at line 249 of file bezier_curves.cpp.

References BEZIER_DBG, VECTOR2< T >::Cross(), VECTOR2< T >::Dot(), and m_ctrlPts.

Referenced by getCubicPoly().

◆ recursiveSegmentation()

void BEZIER_POLY::recursiveSegmentation ( std::vector< VECTOR2D > &  aOutput,
double  aMaxError 
)
private

Definition at line 330 of file bezier_curves.cpp.

References BEZIER_DBG, isFlat(), left, m_ctrlPts, right, and subdivide().

Referenced by cubicParabolicApprox(), and getCubicPoly().

◆ subdivide()

void BEZIER_POLY::subdivide ( double  aT,
BEZIER_POLY aLeft,
BEZIER_POLY aRight 
)
private

Definition at line 292 of file bezier_curves.cpp.

References eval(), and m_ctrlPts.

Referenced by cubicParabolicApprox(), getCubicPoly(), and recursiveSegmentation().

◆ thirdControlPointDeviation()

double BEZIER_POLY::thirdControlPointDeviation ( )
private

Definition at line 275 of file bezier_curves.cpp.

References std::abs(), delta, and m_ctrlPts.

Referenced by cubicParabolicApprox().

Member Data Documentation

◆ m_ctrlPts

◆ m_minSegLen

double BEZIER_POLY::m_minSegLen
private

Control points.

Definition at line 81 of file bezier_curves.h.

Referenced by BEZIER_POLY().


The documentation for this class was generated from the following files: