Bezier
Fast and lightweight class for using the Bezier curves of any order in C++
|
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 | |
PolyCurve & | operator= (const PolyCurve &)=default |
PolyCurve & | operator= (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, Point > | endPoints () 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... | |
Curve & | curve (unsigned idx) |
Get pointer of a subcurve. More... | |
const Curve & | curve (unsigned idx) const |
std::deque< Curve > & | curves () |
Get list of all subcurves. More... | |
const std::deque< Curve > & | curves () const |
Protected Attributes | |
std::deque< Curve > | curves_ |
Structure for holding underlying Bezier curves. | |
A Bezier polycurve class.
A class for linking multiple Bezier curves with at least C0 continuity. It allows subcurve manipulation.
Create the Bezier polycurve from deque of curves.
curve_list | A list of curves |
BoundingBox boundingBox | ( | ) | const |
Get the bounding box of the polycurve.
PointVector controlPoints | ( | ) | const |
Get the control points of all subcurves.
double curvatureAt | ( | double | t | ) | const |
Get curvature of the polycurve for a given t.
t | A Polyurve parameter |
double curvatureDerivativeAt | ( | double | t | ) | const |
Get curvature derivative of curve for a given t.
t | Curve parameter |
Curve& curve | ( | unsigned | idx | ) |
Get pointer of a subcurve.
idx | Subcurve index |
unsigned curveIdx | ( | double | t | ) | const |
Resolve polycurve parameter to subcurve index.
t | A polycurve parameter |
std::deque<Curve>& curves | ( | ) |
Get list of all subcurves.
Vector derivativeAt | ( | double | t | ) | const |
Vector derivativeAt | ( | unsigned | n, |
double | t | ||
) | const |
Get value of an nth derivative for a given t.
n | Desired number of derivative |
t | Curve parameter |
double distance | ( | const Point & | point | ) | const |
Get distance of the point to the polycurve.
point | Point to project on the polycurve |
std::vector<double> distance | ( | const PointVector & | point_vector | ) | const |
Get the distance vector of points to the polycurve.
point_vector | Points to project on the polycurve |
Get first and last control points.
void insertAt | ( | unsigned | idx, |
Curve | curve | ||
) |
Insert new curve into polycurve.
idx | Index where to insert new curve |
curve | A curve to insert |
void insertBack | ( | Curve | curve | ) |
Insert new curve at the end of the polycurve.
curve | A curve to insert |
void insertFront | ( | Curve | curve | ) |
Insert new curve at the beginning of the polycurve.
curve | A curve to insert |
PointVector intersections | ( | const Curve_PolyCurve & | curve | ) | const |
Get the points of intersection with another curve or polycurve.
curve | Curve to intersect with |
double iterateByLength | ( | double | t, |
double | s | ||
) | const |
Compute parameter t which is S distance from given t.
t | Curve parameter |
s | Distance to iterate |
double length | ( | ) | const |
Compute exact arc length using Chebyshev polynomials.
double length | ( | double | t | ) | const |
Compute exact arc length using Chebyshev polynomials.
t | A Polycurve parameter to which length is computed |
double length | ( | double | t1, |
double | t2 | ||
) | const |
Compute exact arc length using Chebyshev polynomials.
t1 | A Polycurve parameter from which length is computed |
t2 | A Polycurve parameter to which length is computed |
Vector normalAt | ( | double | t, |
bool | normalize = true |
||
) | const |
Get the normal of the polycurve for a given t.
t | A Polyurve parameter |
normalize | If the resulting normal should be normalized |
PointVector polyline | ( | double | flatness = 0.5 | ) | const |
Get a polyline representation of the polycurve as a vector of points on curve.
flatness | Error tolerance of approximation |
double projectPoint | ( | const Point & | point | ) | const |
Get the parameter t where polycurve is closest to given point.
point | Point to project on polycurve |
std::vector<double> projectPoint | ( | const PointVector & | point_vector | ) | const |
Get the parameter t vector where polycurve is closest to given points.
point_vector | Points to project on polycurve |
void removeAt | ( | unsigned | idx | ) |
Remove a subcurve from the polycurve.
idx | Index of subcurve to remove |
void setControlPoint | ( | unsigned | idx, |
const Point & | point | ||
) |
Set the new coordinates to a control point.
index | Index of chosen control point |
point | New control point |
unsigned size | ( | ) | const |
Get number of subcurves.
Vector tangentAt | ( | double | t, |
bool | normalize = true |
||
) | const |
Get the tangent of the polycurve for a given t.
t | A Polyurve parameter |
normalize | If the resulting tangent should be normalized |
PointVector valueAt | ( | const std::vector< double > & | t_vector | ) | const |
Get the point vector on polycurve for given parameters.
t_vector | Curve parameters |
Point valueAt | ( | double | t | ) | const |
Get the point on polycurve for a given t.
t | Curve parameter |