|
Bezier 0.4.0
Fast and lightweight class for using the Bezier curves of any order in C++
|
#include <bezier.h>
Public Member Functions | |
| Curve (Eigen::MatrixX2d points) | |
| Create the Bezier curve. | |
| Curve (const PointVector &points) | |
| Create the Bezier curve. | |
| Curve (const Curve &curve) | |
| Curve (Curve &&curve) noexcept | |
| Curve & | operator= (const Curve &curve) |
| Curve & | operator= (Curve &&curve) noexcept |
| unsigned | order () const |
| Get order of the curve (Nth order curve is described with N+1 points) | |
| PointVector | controlPoints () const |
| Get a vector of control points. | |
| Point | controlPoint (unsigned idx) const |
| Get the control point at index idx. | |
| std::pair< Point, Point > | endPoints () const |
| Get first and last control points. | |
| PointVector | polyline () const |
| Get a polyline representation of the curve as a vector of points on curve. | |
| PointVector | polyline (double flatness) const |
| Get a polyline representation of the curve 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. | |
| void | reverse () |
| Reverse order of control points. | |
| void | setControlPoint (unsigned idx, const Point &point) |
| Set the new coordinates to a control point. | |
| void | raiseOrder () |
| Raise the curve order by 1. | |
| void | lowerOrder () |
| Lower the curve order by 1. | |
| Point | valueAt (double t) const |
| Get the point on curve for a given t. | |
| Eigen::MatrixX2d | valueAt (const ParamVector &t_vector) const |
| Get the point vector on curve for given parameters. | |
| double | curvatureAt (double t) const |
| Get curvature of the curve for a given t. | |
| double | curvatureDerivativeAt (double t) const |
| Get curvature derivative of the curve for a given t. | |
| Vector | tangentAt (double t) const |
| Get the unit tangent of the curve for a given t. | |
| Vector | normalAt (double t) const |
| Get the unit normal of the curve for a given t. | |
| const Curve & | derivative () const |
| Get the derivative of a curve. | |
| const Curve & | derivative (unsigned n) const |
| Get the nth derivative of a curve. | |
| 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. | |
| ParamVector | roots () const |
| Get roots of the curve on both axes. | |
| ParamVector | extrema () const |
| Get all extrema of the curve. | |
| BoundingBox | boundingBox () const |
| Get the bounding box of curve. | |
| std::vector< Curve > | splitCurve (const ParamVector &t_vector) const |
| Split the curve into subcurves at multiple parameters. | |
| std::pair< Curve, Curve > | splitCurve (double t=0.5) const |
| Split the curve into two subcurves. | |
| PointVector | intersections (const Curve &curve) const |
| Get the points of intersection with another curve. | |
| double | projectPoint (const Point &point) const |
| Get the parameter t where curve is closest to given point. | |
| double | distance (const Point &point) const |
| Get distance of the point to the curve. | |
| void | applyContinuity (const Curve &curve, const std::vector< double > &beta_coeffs) |
| Apply geometric continuity based on another curve. | |
Static Public Member Functions | |
| static Curve | offsetCurve (const Curve &curve, double offset, unsigned order=0) |
| Fit a Bezier approximation of the curve offset by a given distance. | |
| static Curve | joinCurves (const Curve &curve1, const Curve &curve2, unsigned order=0) |
| Fit a single Bezier curve through two curves joined end to end. | |
| static Curve | fromPolyline (const PointVector &polyline, unsigned order=0) |
| Fit a Bezier curve to an ordered polyline. | |
A Bezier curve class.
A class for storing and using any-order Bezier curve. It uses private and static caching for storing often accessed data. Private caching is used for data concerning individual curve, while static caching is used for common data (coefficient matrices)
| Curve | ( | Eigen::MatrixX2d | points | ) |
Create the Bezier curve.
| points | Nx2 matrix where each row is one of N control points that define the curve |
| Curve | ( | const PointVector & | points | ) |
Create the Bezier curve.
| points | A vector of control points that define the curve |
| void applyContinuity | ( | const Curve & | curve, |
| const std::vector< double > & | beta_coeffs | ||
| ) |
Apply geometric continuity based on another curve.
Glues the start of this curve to the end of the given curve.
| curve | Curve on which calculations are based |
| beta_coeffs | Beta-constraints used to calculate continuity. Size defines continuity order. |
| BoundingBox boundingBox | ( | ) | const |
Get the bounding box of curve.
| Point controlPoint | ( | unsigned | idx | ) | const |
Get the control point at index idx.
| idx | Index of chosen control point |
| PointVector controlPoints | ( | ) | const |
Get a vector of control points.
| double curvatureAt | ( | double | t | ) | const |
Get curvature of the curve for a given t.
| t | Curve parameter |
| double curvatureDerivativeAt | ( | double | t | ) | const |
Get curvature derivative of the curve for a given t.
| t | Curve parameter |
| const Curve & derivative | ( | ) | const |
Get the derivative of a curve.
| const Curve & derivative | ( | unsigned | n | ) | const |
Get the nth derivative of a curve.
| n | Desired number of derivative |
| 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 curve.
| point | Point to project on curve |
Get first and last control points.
| ParamVector extrema | ( | ) | const |
Get all extrema of the curve.
|
static |
Fit a Bezier curve to an ordered polyline.
| polyline | Polyline vertices to approximate |
| order | Order of the fitted curve; 0 selects it automatically |
| std::logic_error | if the polyline has fewer than two points |
| PointVector intersections | ( | const Curve & | curve | ) | const |
Get the points of intersection with another curve.
| curve | Curve to intersect with |
Fit a single Bezier curve through two curves joined end to end.
| curve1 | First curve |
| curve2 | Second curve |
| order | Order of the resulting curve; 0 selects it automatically |
| double length | ( | ) | const |
Compute exact arc length using Chebyshev polynomials.
| double length | ( | double | t | ) | const |
Compute exact arc length using Chebyshev polynomials.
| t | Curve parameter to which length is computed |
| std::logic_error | if t is outside [0.0, 1.0] |
| double length | ( | double | t1, |
| double | t2 | ||
| ) | const |
| void lowerOrder | ( | ) |
Lower the curve order by 1.
If current shape cannot be described by lower order, it will be best approximation
| std::logic_error | if the curve is already 1st order |
| Vector normalAt | ( | double | t | ) | const |
Get the unit normal of the curve for a given t.
| t | Curve parameter |
Fit a Bezier approximation of the curve offset by a given distance.
| curve | Source curve |
| offset | Offset distance (positive to the left of the curve's direction, negative to the right) |
| order | Order of the resulting curve; 0 selects it automatically |
| unsigned order | ( | ) | const |
Get order of the curve (Nth order curve is described with N+1 points)
| PointVector polyline | ( | ) | const |
Get a polyline representation of the curve as a vector of points on curve.
| PointVector polyline | ( | double | flatness | ) | const |
Get a polyline representation of the curve as a vector of points on curve.
| flatness | Error tolerance of approximation |
| ParamVector polylineParams | ( | ) | const |
Get curve parameters corresponding to polyline points.
| ParamVector polylineParams | ( | double | flatness | ) | const |
Get curve parameters corresponding to polyline points.
| flatness | Error tolerance of approximation |
| double projectPoint | ( | const Point & | point | ) | const |
Get the parameter t where curve is closest to given point.
| point | Point to project on curve |
| void raiseOrder | ( | ) |
| void reverse | ( | ) |
Reverse order of control points.
| ParamVector roots | ( | ) | const |
Get roots of the curve on both axes.
| void setControlPoint | ( | unsigned | idx, |
| const Point & | point | ||
| ) |
Set the new coordinates to a control point.
| idx | Index of chosen control point |
| point | New control point |
| std::vector< Curve > splitCurve | ( | const ParamVector & | t_vector | ) | const |
Split the curve into subcurves at multiple parameters.
| t_vector | Vector of curve parameters at which to split the curve |
Split the curve into two subcurves.
| t | Curve parameter at which to split the curve |
| double step | ( | double | t, |
| double | ds | ||
| ) | const |
Compute parameter t which is ds distance from given t.
| t | Curve parameter |
| ds | Distance to iterate |
| std::logic_error | if t is outside [0.0, 1.0] |
| Vector tangentAt | ( | double | t | ) | const |
Get the unit tangent of the curve for a given t.
| t | Curve parameter |
| Eigen::MatrixX2d valueAt | ( | const ParamVector & | t_vector | ) | const |
Get the point vector on curve for given parameters.
| t_vector | Curve parameters |
| Point valueAt | ( | double | t | ) | const |
Get the point on curve for a given t.
| t | Curve parameter |