Bezier
Fast and lightweight class for using the Bezier curves of any order in C++
PolyCurve Class Reference

A Bezier polycurve class. More...

#include <polycurve.h>

Public Member Functions

 PolyCurve (std::deque< Curve > curves)
 Create the Bezier polycurve from deque of curves. More...
 
 PolyCurve (const PolyCurve &)=default
 
 PolyCurve (PolyCurve &&)=default
 
PolyCurveoperator= (const PolyCurve &)=default
 
PolyCurveoperator= (PolyCurve &&)=default
 
void insertAt (unsigned idx, Curve curve)
 Insert new curve into polycurve. More...
 
void insertFront (Curve curve)
 Insert new curve at the beginning of the polycurve. More...
 
void insertBack (Curve curve)
 Insert new curve at the end of the polycurve. More...
 
void removeAt (unsigned idx)
 Remove a subcurve from the polycurve. More...
 
void removeFirst ()
 Remove a subcurve from the beginning of the polycurve.
 
void removeBack ()
 Remove a subcurve from the end of the polycurve.
 
unsigned size () const
 Get number of subcurves. More...
 
unsigned curveIdx (double t) const
 Resolve polycurve parameter to subcurve index. More...
 
PointVector polyline (double flatness=0.5) const
 Get a polyline representation of the polycurve as a vector of points on curve. More...
 
double length () const
 Compute exact arc length using Chebyshev polynomials. More...
 
double length (double t) const
 Compute exact arc length using Chebyshev polynomials. More...
 
double length (double t1, double t2) const
 Compute exact arc length using Chebyshev polynomials. More...
 
double iterateByLength (double t, double s) const
 Compute parameter t which is S distance from given t. More...
 
std::pair< Point, PointendPoints () const
 Get first and last control points. More...
 
PointVector controlPoints () const
 Get the control points of all subcurves. More...
 
void setControlPoint (unsigned idx, const Point &point)
 Set the new coordinates to a control point. More...
 
Point valueAt (double t) const
 Get the point on polycurve for a given t. More...
 
PointVector valueAt (const std::vector< double > &t_vector) const
 Get the point vector on polycurve for given parameters. More...
 
double curvatureAt (double t) const
 Get curvature of the polycurve for a given t. More...
 
double curvatureDerivativeAt (double t) const
 Get curvature derivative of curve for a given t. More...
 
Vector tangentAt (double t, bool normalize=true) const
 Get the tangent of the polycurve for a given t. More...
 
Vector normalAt (double t, bool normalize=true) const
 Get the normal of the polycurve for a given t. More...
 
Vector derivativeAt (double t) const
 Get value of a derivative for a given t. More...
 
Vector derivativeAt (unsigned n, double t) const
 Get value of an nth derivative for a given t. More...
 
BoundingBox boundingBox () const
 Get the bounding box of the polycurve. More...
 
template<typename Curve_PolyCurve >
PointVector intersections (const Curve_PolyCurve &curve) const
 Get the points of intersection with another curve or polycurve. More...
 
double projectPoint (const Point &point) const
 Get the parameter t where polycurve is closest to given point. More...
 
std::vector< double > projectPoint (const PointVector &point_vector) const
 Get the parameter t vector where polycurve is closest to given points. More...
 
double distance (const Point &point) const
 Get distance of the point to the polycurve. More...
 
std::vector< double > distance (const PointVector &point_vector) const
 Get the distance vector of points to the polycurve. More...
 
Curvecurve (unsigned idx)
 Get pointer of a subcurve. More...
 
const Curvecurve (unsigned idx) const
 
std::deque< Curve > & curves ()
 Get list of all subcurves. More...
 
const std::deque< Curve > & curves () const
 

Protected Attributes

std::deque< Curvecurves_
 Structure for holding underlying Bezier curves.
 

Detailed Description

A Bezier polycurve class.

A class for linking multiple Bezier curves with at least C0 continuity. It allows subcurve manipulation.

Warning
Range of parameter 't' depends on number of subcurves. To access n-th subcurve, t has to be in range [n-1, n>

Constructor & Destructor Documentation

◆ PolyCurve()

PolyCurve ( std::deque< Curve curves)

Create the Bezier polycurve from deque of curves.

Parameters
curve_listA list of curves

Member Function Documentation

◆ boundingBox()

BoundingBox boundingBox ( ) const

Get the bounding box of the polycurve.

Returns
Bounding box

◆ controlPoints()

PointVector controlPoints ( ) const

Get the control points of all subcurves.

Returns
A vector of control points

◆ curvatureAt()

double curvatureAt ( double  t) const

Get curvature of the polycurve for a given t.

Parameters
tA Polyurve parameter
Returns
Curvature of a polycurve for a given t

◆ curvatureDerivativeAt()

double curvatureDerivativeAt ( double  t) const

Get curvature derivative of curve for a given t.

Parameters
tCurve parameter
Returns
Curvature derivative of a curve for a given t

◆ curve()

Curve& curve ( unsigned  idx)

Get pointer of a subcurve.

Parameters
idxSubcurve index
Returns
A reference to curve

◆ curveIdx()

unsigned curveIdx ( double  t) const

Resolve polycurve parameter to subcurve index.

Parameters
tA polycurve parameter
Returns
An index of of subcurve where parameter t is

◆ curves()

std::deque<Curve>& curves ( )

Get list of all subcurves.

Returns
A vector of curve references

◆ derivativeAt() [1/2]

Vector derivativeAt ( double  t) const

Get value of a derivative for a given t.

Parameters
tCurve parameter
Returns
Curve derivative at t

◆ derivativeAt() [2/2]

Vector derivativeAt ( unsigned  n,
double  t 
) const

Get value of an nth derivative for a given t.

Parameters
nDesired number of derivative
tCurve parameter
Returns
nth curve derivative at t

◆ distance() [1/2]

double distance ( const Point point) const

Get distance of the point to the polycurve.

Parameters
pointPoint to project on the polycurve
Returns
Distance to the curve

◆ distance() [2/2]

std::vector<double> distance ( const PointVector point_vector) const

Get the distance vector of points to the polycurve.

Parameters
point_vectorPoints to project on the polycurve
Returns
Vector of distances

◆ endPoints()

std::pair<Point, Point> endPoints ( ) const

Get first and last control points.

Returns
A pair of end points

◆ insertAt()

void insertAt ( unsigned  idx,
Curve  curve 
)

Insert new curve into polycurve.

Parameters
idxIndex where to insert new curve
curveA curve to insert

◆ insertBack()

void insertBack ( Curve  curve)

Insert new curve at the end of the polycurve.

Parameters
curveA curve to insert

◆ insertFront()

void insertFront ( Curve  curve)

Insert new curve at the beginning of the polycurve.

Parameters
curveA curve to insert

◆ intersections()

PointVector intersections ( const Curve_PolyCurve &  curve) const

Get the points of intersection with another curve or polycurve.

Parameters
curveCurve to intersect with
Returns
A vector af points of intersection between curves

◆ iterateByLength()

double iterateByLength ( double  t,
double  s 
) const

Compute parameter t which is S distance from given t.

Parameters
tCurve parameter
sDistance to iterate
Returns
New parameter t

◆ length() [1/3]

double length ( ) const

Compute exact arc length using Chebyshev polynomials.

Returns
Arc length

◆ length() [2/3]

double length ( double  t) const

Compute exact arc length using Chebyshev polynomials.

Parameters
tA Polycurve parameter to which length is computed
Returns
Arc length from start to parameter t

◆ length() [3/3]

double length ( double  t1,
double  t2 
) const

Compute exact arc length using Chebyshev polynomials.

Parameters
t1A Polycurve parameter from which length is computed
t2A Polycurve parameter to which length is computed
Returns
Arc length between paramaters t1 and t2

◆ normalAt()

Vector normalAt ( double  t,
bool  normalize = true 
) const

Get the normal of the polycurve for a given t.

Parameters
tA Polyurve parameter
normalizeIf the resulting normal should be normalized
Returns
Normal of a polycurve for given t

◆ polyline()

PointVector polyline ( double  flatness = 0.5) const

Get a polyline representation of the polycurve as a vector of points on curve.

Parameters
flatnessError tolerance of approximation
Returns
A vector of polyline vertices

◆ projectPoint() [1/2]

double projectPoint ( const Point point) const

Get the parameter t where polycurve is closest to given point.

Parameters
pointPoint to project on polycurve
Returns
double t

◆ projectPoint() [2/2]

std::vector<double> projectPoint ( const PointVector point_vector) const

Get the parameter t vector where polycurve is closest to given points.

Parameters
point_vectorPoints to project on polycurve
Returns
Vector of parameters t

◆ removeAt()

void removeAt ( unsigned  idx)

Remove a subcurve from the polycurve.

Parameters
idxIndex of subcurve to remove

◆ setControlPoint()

void setControlPoint ( unsigned  idx,
const Point point 
)

Set the new coordinates to a control point.

Parameters
indexIndex of chosen control point
pointNew control point

◆ size()

unsigned size ( ) const

Get number of subcurves.

Returns
Number of subcurves

◆ tangentAt()

Vector tangentAt ( double  t,
bool  normalize = true 
) const

Get the tangent of the polycurve for a given t.

Parameters
tA Polyurve parameter
normalizeIf the resulting tangent should be normalized
Returns
Tangent of a polycurve for a given t

◆ valueAt() [1/2]

PointVector valueAt ( const std::vector< double > &  t_vector) const

Get the point vector on polycurve for given parameters.

Parameters
t_vectorCurve parameters
Returns
Vector of points on a polycurve for given parameters

◆ valueAt() [2/2]

Point valueAt ( double  t) const

Get the point on polycurve for a given t.

Parameters
tCurve parameter
Returns
Point on a polycurve for a given t

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