Description
Definition of a piece-wise cubic Bezier approximation of a 3D curve.
This class encapsulates a piece-wise cubic Bezier approximation of a 3D curve, represented as a set of three arrays of locations. For each point on the curve, we also define a vector 'inCV' which represents the vertex of the control polygon prior to the point and a vector 'outCV' which represents the vertex of the control polygon following the point. This class provides methods for evaluating the value, as well as the first and second derivatives of a point on a specified interval of the piece-wise 3D curve (using the Bernstein polynomial representation of Bezier curves). In addition, it provides a method for calculating the closest point on a specified interval of the curve to a specified location.
#include <ChBezierCurve.h>
Public Member Functions | |
ChBezierCurve (const std::vector< ChVector<> > &points, const std::vector< ChVector<> > &inCV, const std::vector< ChVector<> > &outCV) | |
Constructor from specified nodes and control points. | |
ChBezierCurve (const std::vector< ChVector<> > &points) | |
Constructor from specified nodes. More... | |
ChBezierCurve () | |
Default constructor (required by serialization) | |
~ChBezierCurve () | |
Destructor for ChBezierCurve. | |
void | setPoints (const std::vector< ChVector<> > &points, const std::vector< ChVector<> > &inCV, const std::vector< ChVector<> > &outCV) |
Set the nodes and control points. | |
size_t | getNumPoints () const |
Return the number of knot points. | |
const ChVector & | getPoint (size_t i) const |
Return the knot point with specified index. | |
ChVector | eval (double t) const |
Evaluate the value of the Bezier curve. More... | |
ChVector | eval (size_t i, double t) const |
Evaluate the value of the Bezier curve. More... | |
ChVector | evalD (size_t i, double t) const |
Evaluate the tangent vector to the Bezier curve. More... | |
ChVector | evalDD (size_t i, double t) const |
Evaluate the second derivative vector to the Bezier curve. More... | |
ChVector | calcClosestPoint (const ChVector<> &loc, size_t i, double &t) const |
Calculate the closest point on the curve to the given location. More... | |
void | write (const std::string &filename) |
Write the knots and control points to the specified file. | |
void | ArchiveOUT (ChArchiveOut &marchive) |
Method to allow serialization of transient data to archives. | |
void | ArchiveIN (ChArchiveIn &marchive) |
Method to allow de-serialization of transient data from archives. | |
Static Public Member Functions | |
static std::shared_ptr< ChBezierCurve > | read (const std::string &filename) |
Create a ChBezierCurve using data in the specified file. More... | |
Friends | |
class | ChBezierCurveTracker |
Constructor & Destructor Documentation
◆ ChBezierCurve()
chrono::ChBezierCurve::ChBezierCurve | ( | const std::vector< ChVector<> > & | points | ) |
Constructor from specified nodes.
In this case, we evaluate the control polygon vertices inCV and outCV so that we obtain a piecewise cubic spline interpolant of the given knots.
Member Function Documentation
◆ calcClosestPoint()
ChVector chrono::ChBezierCurve::calcClosestPoint | ( | const ChVector<> & | loc, |
size_t | i, | ||
double & | t | ||
) | const |
Calculate the closest point on the curve to the given location.
This function calculates and returns the point on the curve in the specified interval that is closest to the specified location. On input, the value 't' is an initial guess. On return, it contains the curve parameter corresponding to the closest point.
◆ eval() [1/2]
ChVector chrono::ChBezierCurve::eval | ( | double | t | ) | const |
Evaluate the value of the Bezier curve.
This function calculates and returns the point on the curve at the given curve parameter (assumed to be in [0,1]).
A value t=0 returns the first point on the curve. A value t=1 returns the last point on the curve.
◆ eval() [2/2]
ChVector chrono::ChBezierCurve::eval | ( | size_t | i, |
double | t | ||
) | const |
Evaluate the value of the Bezier curve.
This function calculates and returns the point on the curve in the specified interval between two knot points and at the given curve parameter (assumed to be in [0,1]). A value t-0 returns the first end of the specified interval. A value t=1 return the second end of the specified interval. It uses the Bernstein polynomial representation of a Bezier curve.
◆ evalD()
ChVector chrono::ChBezierCurve::evalD | ( | size_t | i, |
double | t | ||
) | const |
Evaluate the tangent vector to the Bezier curve.
This function calculates and returns the first derivative (tangent vector) to the curve in the specified interval between two knot points and at the given curve parameter (assumed to be in [0,1]). It uses the Bernstein polynomial representation of a Bezier curve.
◆ evalDD()
ChVector chrono::ChBezierCurve::evalDD | ( | size_t | i, |
double | t | ||
) | const |
Evaluate the second derivative vector to the Bezier curve.
This function calculates and returns the second derivative vector to the curve in the specified interval between two knot points and at the given curve parameter (assumed to be in [0,1]). It uses the Bernstein polynomial representation of a Bezier curve.
◆ read()
|
static |
Create a ChBezierCurve using data in the specified file.
The input file is assumed to contain on the first line the number of data points and the number of data columns. The latter can be one of 3 or 9. In the first case, subsequent lines should contain the coordinates of the curve knots (one point per line). The returned Bezier curve is a piecewise cubic spline through the specified points. In the second case, subsequent lines should contain the coordinates of the curve knot, the coordinates of the "incoming" control point, and the coordinates of the "outgoing" control point (i.e. 9 values per line). The returned curve is a general Bezier curve using the specified knots and control polygons.
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono/core/ChBezierCurve.h
- /builds/uwsbel/chrono/src/chrono/core/ChBezierCurve.cpp