Bezier 0.4.0
Fast and lightweight class for using the Bezier curves of any order in C++
Loading...
Searching...
No Matches
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.
 
 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.
 
void insertFront (Curve curve)
 Insert new curve at the beginning of the polycurve.
 
void insertBack (Curve curve)
 Insert new curve at the end of the polycurve.
 
void removeAt (unsigned idx)
 Remove a subcurve from the polycurve.
 
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.
 
unsigned curveIdx (double t) const
 Resolve polycurve parameter to subcurve index.
 
PointVector polyline () const
 Get a polyline representation of the polycurve as a vector of points on curve.
 
PointVector polyline (double flatness) const
 Get a polyline representation of the polycurve as a vector of points on curve.
 
ParamVector polylineParams () const
 Get curve parameters corresponding to polyline points.
 
ParamVector polylineParams (double flatness) const
 Get curve parameters corresponding to polyline points.
 
double length () const
 Compute exact arc length using Chebyshev polynomials.
 
double length (double t) const
 Compute exact arc length using Chebyshev polynomials.
 
double length (double t1, double t2) const
 Compute exact arc length using Chebyshev polynomials.
 
double step (double t, double ds) const
 Compute parameter t which is ds distance from given t.
 
std::pair< Point, PointendPoints () const
 Get first and last control points.
 
PointVector controlPoints () const
 Get the control points of all subcurves.
 
void setControlPoint (unsigned idx, const Point &point)
 Set the new coordinates to a control point.
 
Point valueAt (double t) const
 Get the point on polycurve for a given t.
 
PointVector valueAt (const ParamVector &t_vector) const
 Get the point vector on polycurve for given parameters.
 
double curvatureAt (double t) const
 Get curvature of the polycurve for a given t.
 
double curvatureDerivativeAt (double t) const
 Get curvature derivative of the polycurve for a given t.
 
Vector tangentAt (double t) const
 Get the unit tangent of the polycurve for a given t.
 
Vector normalAt (double t) const
 Get the unit normal of the polycurve for a given t.
 
Vector derivativeAt (double t) const
 Get value of a derivative for a given t.
 
Vector derivativeAt (unsigned n, double t) const
 Get value of an nth derivative for a given t.
 
BoundingBox boundingBox () const
 Get the bounding box of the polycurve.
 
double projectPoint (const Point &point) const
 Get the parameter t where polycurve is closest to given point.
 
ParamVector projectPoint (const PointVector &point_vector) const
 Get the parameter t vector where polycurve is closest to given points.
 
double distance (const Point &point) const
 Get distance of the point to the polycurve.
 
std::vector< double > distance (const PointVector &point_vector) const
 Get the distance vector of points to the polycurve.
 
Curvecurve (unsigned idx)
 Get a subcurve.
 
const Curvecurve (unsigned idx) const
 Get a subcurve.
 
std::deque< Curve > & curves ()
 Get list of all subcurves.
 
const std::deque< Curve > & curves () const
 Get list of all subcurves.
 
PointVector intersections (const Curve &curve) const
 Get the points of intersection with another curve or polycurve.
 
PointVector intersections (const PolyCurve &curve) const
 Get the points of intersection with another curve or polycurve.
 

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)
Note
Parameter-taking accessors throw std::logic_error on an empty polycurve.

Constructor & Destructor Documentation

◆ PolyCurve()

PolyCurve ( std::deque< Curve curves)

Create the Bezier polycurve from deque of curves.

Parameters
curvesA 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 Polycurve parameter
Returns
Curvature of a polycurve for a given t

◆ curvatureDerivativeAt()

double curvatureDerivativeAt ( double  t) const

Get curvature derivative of the polycurve for a given t.

Parameters
tA Polycurve parameter
Returns
Curvature derivative of a polycurve for a given t

◆ curve() [1/2]

Curve & curve ( unsigned  idx)

Get a subcurve.

Parameters
idxSubcurve index
Returns
A reference to the subcurve at idx
Note
idx must be in range [0, size())

◆ curve() [2/2]

const Curve & curve ( unsigned  idx) const

Get a subcurve.

Parameters
idxSubcurve index
Returns
A reference to the subcurve at idx
Note
idx must be in range [0, size())

◆ curveIdx()

unsigned curveIdx ( double  t) const

Resolve polycurve parameter to subcurve index.

Parameters
tA polycurve parameter
Returns
An index of the subcurve where parameter t is
Note
t is clamped into [0, size()]
Exceptions
std::logic_errorif the polycurve is empty

◆ curves() [1/2]

std::deque< Curve > & curves ( )

Get list of all subcurves.

Returns
A reference to the deque of subcurves

◆ curves() [2/2]

const std::deque< Curve > & curves ( ) const

Get list of all subcurves.

Returns
A reference to the deque of subcurves

◆ 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
Exceptions
std::logic_errorif the polycurve is empty

◆ insertAt()

void insertAt ( unsigned  idx,
Curve  curve 
)

Insert new curve into polycurve.

Parameters
idxIndex where to insert new curve
curveA curve to insert
Note
idx must be in range [0, size()]

◆ 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() [1/2]

PointVector intersections ( const Curve curve) const

Get the points of intersection with another curve or polycurve.

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

◆ intersections() [2/2]

PointVector intersections ( const PolyCurve curve) const

Get the points of intersection with another curve or polycurve.

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

◆ 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 parameters t1 and t2

◆ normalAt()

Vector normalAt ( double  t) const

Get the unit normal of the polycurve for a given t.

Parameters
tA Polycurve parameter
Returns
Unit normal of a polycurve for given t

◆ polyline() [1/2]

PointVector polyline ( ) const

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

Returns
A vector of polyline vertices
Note
Each subcurve uses its own auto-calculated flatness (0.1% of bounding box diagonal)

◆ polyline() [2/2]

PointVector polyline ( double  flatness) 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

◆ polylineParams() [1/2]

ParamVector polylineParams ( ) const

Get curve parameters corresponding to polyline points.

Returns
A vector of curve parameters for each polyline vertex
Note
Each subcurve uses its own auto-calculated flatness (0.1% of bounding box diagonal)

◆ polylineParams() [2/2]

ParamVector polylineParams ( double  flatness) const

Get curve parameters corresponding to polyline points.

Parameters
flatnessError tolerance of approximation
Returns
A vector of curve parameters for each polyline vertex

◆ 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]

ParamVector 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
Note
idx must be in range [0, size())

◆ removeBack()

void removeBack ( )

Remove a subcurve from the end of the polycurve.

Note
Requires a non-empty polycurve

◆ removeFirst()

void removeFirst ( )

Remove a subcurve from the beginning of the polycurve.

Note
Requires a non-empty polycurve

◆ setControlPoint()

void setControlPoint ( unsigned  idx,
const Point point 
)

Set the new coordinates to a control point.

Parameters
idxGlobal control-point index across all subcurves
pointNew control point
Note
No-op if idx is out of range

◆ size()

unsigned size ( ) const

Get number of subcurves.

Returns
Number of subcurves

◆ step()

double step ( double  t,
double  ds 
) const

Compute parameter t which is ds distance from given t.

Parameters
tCurve parameter
dsDistance to iterate
Returns
New parameter t

◆ tangentAt()

Vector tangentAt ( double  t) const

Get the unit tangent of the polycurve for a given t.

Parameters
tA Polycurve parameter
Returns
Unit tangent of a polycurve for a given t

◆ valueAt() [1/2]

PointVector valueAt ( const ParamVector 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: