|
AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Represents a Bezier curve defined by an array of control points. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/primal/geometry/BezierCurve.hpp>
Public Types | |
| using | NumericType = T |
| using | PointType = Point< T, NDIMS > |
| using | VectorType = Vector< T, NDIMS > |
| using | SegmentType = Segment< T, NDIMS > |
| using | WeightsVec = axom::Array< T > |
| using | CoordsVec = axom::Array< PointType > |
| using | BoundingBoxType = BoundingBox< T, NDIMS > |
| using | OrientedBoundingBoxType = OrientedBoundingBox< T, NDIMS > |
Public Member Functions | |
| AXOM_STATIC_ASSERT_MSG ((NDIMS==1)||(NDIMS==2)||(NDIMS==3), "A Bezier Curve object may be defined in 1-, 2-, or 3-D") | |
| AXOM_STATIC_ASSERT_MSG (std::is_arithmetic< T >::value, "A Bezier Curve must be defined using an arithmetic type") | |
| std::ostream & | print (std::ostream &os) const |
| Simple formatted print of a Bezier Curve instance. More... | |
Constructors for polynomial and rational Bezier curves | |
The constructors allow for flexible initialization of BezierCurve objects from:
The curve is parametrized from t=0 to t=1. Rational curves are identified by a non-empty weights array, and nonrational curves by an empty weights array. All weights must be greater than 0 in a rational curve. | |
| BezierCurve (axom::ArrayView< const PointType > controlPoints, axom::ArrayView< const T > weights, int ord) | |
| Constructor for a Bezier Curve from ArrayViews of control points and weights. More... | |
| BezierCurve (axom::ArrayView< PointType > pts, axom::ArrayView< T > weights, int ord) | |
| Constructor for a Bezier Curve from ArrayViews of (non-const) control points and weights. More... | |
| BezierCurve (int ord=-1) | |
| Constructor for a polynomial Bezier Curve that reserves space for the control points. More... | |
| BezierCurve (const PointType *pts, int ord) | |
| Constructor for a polynomial Bezier Curve from an array of coordinates. More... | |
| BezierCurve (const PointType *pts, const T *weights, int ord) | |
| Constructor for a rational Bezier Curve from an array of coordinates and weights. More... | |
| BezierCurve (const axom::Array< PointType > &pts, int ord) | |
| Constructor for a Bezier Curve from an array of coordinates. More... | |
| BezierCurve (const axom::Array< PointType > &pts, const axom::Array< T > &weights, int ord) | |
| Constructor for a rational Bezier Curve from arrays of coordinates and weights. More... | |
Query/modify curve properties (order, rationality, ...) | |
| void | setOrder (int ord) |
| Sets the order of the Bezier Curve. More... | |
| int | getOrder () const |
| Returns the order of the Bezier Curve. More... | |
| int | getNumControlPoints () const |
| Returns the number of control points of the Bezier Curve. More... | |
| void | clear () |
| Clears the list of control points, make nonrational. More... | |
| bool | isRational () const |
| Use array size as flag for rationality. More... | |
| void | makeRational () |
| Make trivially rational. If already rational, do nothing. More... | |
| void | makeNonrational () |
| Make nonrational by shrinking array of weights. More... | |
Query/modify curve's geometry (control points, weights, bounding box, ...) | |
| PointType & | operator[] (int idx) |
| Retrieves the control point at index idx. More... | |
| const PointType & | operator[] (int idx) const |
| Retrieves the control point at index idx. More... | |
| const PointType & | getInitPoint () const |
| const PointType & | getEndPoint () const |
| CoordsVec & | getControlPoints () |
| Returns a reference to the Bezier curve's control points. More... | |
| const CoordsVec & | getControlPoints () const |
| Returns a const reference to the Bezier curve's control points. More... | |
| const T & | getWeight (int idx) const |
| Get a specific weight. More... | |
| void | setWeight (int idx, T weight) |
| Set the weight at a specific index. More... | |
| WeightsVec & | getWeights () |
| Returns a reference of the Bezier curve's weights. More... | |
| const WeightsVec & | getWeights () const |
| Returns a const reference of the Bezier curve's weights. More... | |
| BoundingBoxType | boundingBox () const |
| Returns an axis-aligned bounding box containing the Bezier curve. More... | |
| OrientedBoundingBoxType | orientedBoundingBox () const |
| Returns an oriented bounding box containing the Bezier curve. More... | |
| bool | isLinear (double tol=1e-8, bool useStrictLinear=false) const |
| Predicate to check if the Bezier curve is approximately linear. More... | |
Query/modify curve parametrization | |
| void | reverseOrientation () |
| Reverses the order of the Bezier curve's control points and weights. More... | |
Functions to evaluate curve and its derivatives and normals | |
| PointType | evaluate (T t) const |
| Evaluates a Bezier curve at a particular parameter value t. More... | |
| void | evaluateFirstDerivative (T t, PointType &eval, VectorType &Dt) const |
| Computes the 0th and 1st derivative of a Bezier curve. More... | |
| VectorType | dt (T t) const |
| Computes the tangent of a Bezier curve at a particular parameter value t. More... | |
| void | evaluateSecondDerivative (T t, PointType &eval, VectorType &Dt, VectorType &DtDt) const |
| Computes the 0th, 1st, and 2nd derivatives of a Bezier curve. More... | |
| VectorType | dtdt (T t) const |
| Computes the second derivative of a Bezier curve at a particular parameter value t. More... | |
Functions dealing with curve subdivision | |
| void | split (T t, BezierCurve &c1, BezierCurve &c2) const |
| Splits a Bezier curve into two Bezier curves at a given parameter value. More... | |
Friends | |
| bool | operator== (const BezierCurve< T, NDIMS > &lhs, const BezierCurve< T, NDIMS > &rhs) |
| Checks equality of two Bezier Curve. More... | |
| bool | operator!= (const BezierCurve< T, NDIMS > &lhs, const BezierCurve< T, NDIMS > &rhs) |
Represents a Bezier curve defined by an array of control points.
| T | the coordinate type, e.g., double, float, etc. |
| NDIMS | the number of dimensions |
The order of a Bezier curve with N+1 control points is N. The curve is approximated by the control points, parametrized from t=0 to t=1.
Contains an array of positive weights to represent a rational Bezier curve. Nonrational Bezier curves are identified by an empty weights array. Algorithms for Rational Bezier curves derived from Gerald Farin, "Algorithms for rational Bezier curves" Computer-Aided Design, Volume 15, Number 2, 1983,
| using axom::primal::BezierCurve< T, NDIMS >::NumericType = T |
| using axom::primal::BezierCurve< T, NDIMS >::PointType = Point<T, NDIMS> |
| using axom::primal::BezierCurve< T, NDIMS >::VectorType = Vector<T, NDIMS> |
| using axom::primal::BezierCurve< T, NDIMS >::SegmentType = Segment<T, NDIMS> |
| using axom::primal::BezierCurve< T, NDIMS >::WeightsVec = axom::Array<T> |
| using axom::primal::BezierCurve< T, NDIMS >::CoordsVec = axom::Array<PointType> |
| using axom::primal::BezierCurve< T, NDIMS >::BoundingBoxType = BoundingBox<T, NDIMS> |
| using axom::primal::BezierCurve< T, NDIMS >::OrientedBoundingBoxType = OrientedBoundingBox<T, NDIMS> |
|
inline |
Constructor for a Bezier Curve from ArrayViews of control points and weights.
| [in] | controlPoints | ArrayView with zero or ord+1 control points |
| [in] | weights | ArrayView with zero or ord+1 positive weights |
| [in] | ord | The Curve's polynomial order |
If controlPoints is empty, we still allocate space for ord+1 control points
References axom::ArrayView< T, DIM, SPACE >::data(), axom::ArrayView< T, DIM, SPACE >::empty(), axom::primal::BezierCurve< T, NDIMS >::isRational(), axom::utilities::max(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), axom::ArrayView< T, DIM, SPACE >::size(), and SLIC_ASSERT.
|
inline |
Constructor for a Bezier Curve from ArrayViews of (non-const) control points and weights.
|
inlineexplicit |
Constructor for a polynomial Bezier Curve that reserves space for the control points.
| [in] | order | the order of the resulting Bezier curve |
|
inline |
Constructor for a polynomial Bezier Curve from an array of coordinates.
| [in] | pts | a vector with ord+1 control points |
| [in] | ord | The Curve's polynomial order |
|
inline |
Constructor for a rational Bezier Curve from an array of coordinates and weights.
| [in] | pts | a vector with ord+1 control points |
| [in] | weights | a vector with ord+1 positive weights |
| [in] | ord | The Curve's polynomial order |
|
inline |
Constructor for a Bezier Curve from an array of coordinates.
| [in] | pts | an array with ord+1 control points |
| [in] | ord | The Curve's polynomial order |
|
inline |
Constructor for a rational Bezier Curve from arrays of coordinates and weights.
| [in] | pts | an array with ord+1 control points |
| [in] | weights | an array with ord+1 positive weights |
| [in] | ord | The Curve's polynomial order |
| axom::primal::BezierCurve< T, NDIMS >::AXOM_STATIC_ASSERT_MSG | ( | (NDIMS==1)||(NDIMS==2)||(NDIMS==3) | , |
| "A Bezier Curve object may be defined in 1- | , | ||
| 2- | , | ||
| or 3-D" | |||
| ) |
| axom::primal::BezierCurve< T, NDIMS >::AXOM_STATIC_ASSERT_MSG | ( | std::is_arithmetic< T >::value | , |
| "A Bezier Curve must be defined using an arithmetic type" | |||
| ) |
|
inline |
Sets the order of the Bezier Curve.
References axom::primal::BezierCurve< T, NDIMS >::isRational(), axom::utilities::max(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), and SLIC_ASSERT.
|
inline |
Returns the order of the Bezier Curve.
References axom::Array< T, DIM, SPACE, StoragePolicy >::size().
|
inline |
Returns the number of control points of the Bezier Curve.
References axom::Array< T, DIM, SPACE, StoragePolicy >::size().
|
inline |
Clears the list of control points, make nonrational.
References axom::Array< T, DIM, SPACE, StoragePolicy >::clear(), and axom::primal::BezierCurve< T, NDIMS >::makeNonrational().
|
inline |
Use array size as flag for rationality.
References axom::Array< T, DIM, SPACE, StoragePolicy >::empty().
|
inline |
Make trivially rational. If already rational, do nothing.
References axom::Array< T, DIM, SPACE, StoragePolicy >::fill(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::Array< T, DIM, SPACE, StoragePolicy >::resize().
|
inline |
Make nonrational by shrinking array of weights.
References axom::Array< T, DIM, SPACE, StoragePolicy >::resize().
|
inline |
Retrieves the control point at index idx.
|
inline |
Retrieves the control point at index idx.
|
inline |
|
inline |
|
inline |
Returns a reference to the Bezier curve's control points.
|
inline |
Returns a const reference to the Bezier curve's control points.
|
inline |
Get a specific weight.
| [in] | idx | The index of the weight |
References axom::primal::BezierCurve< T, NDIMS >::isRational(), and SLIC_ASSERT.
|
inline |
Set the weight at a specific index.
| [in] | idx | The index of the weight |
| [in] | weight | The updated value of the weight |
References axom::primal::BezierCurve< T, NDIMS >::isRational(), and SLIC_ASSERT.
|
inline |
Returns a reference of the Bezier curve's weights.
|
inline |
Returns a const reference of the Bezier curve's weights.
|
inline |
Returns an axis-aligned bounding box containing the Bezier curve.
References axom::Array< T, DIM, SPACE, StoragePolicy >::data(), and axom::Array< T, DIM, SPACE, StoragePolicy >::size().
|
inline |
Returns an oriented bounding box containing the Bezier curve.
References axom::Array< T, DIM, SPACE, StoragePolicy >::data(), and axom::Array< T, DIM, SPACE, StoragePolicy >::size().
|
inline |
Predicate to check if the Bezier curve is approximately linear.
This function checks if the internal control points of the BezierCurve are approximately on the line defined by its two endpoints
| [in] | tol | Threshold for sum of squared distances |
| [in] | useStrictLinear | If true, checks that the control points are evenly spaced along the line and not too far from the line |
References axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::Point< T, NDIMS >::lerp(), and axom::primal::squared_distance().
|
inline |
Reverses the order of the Bezier curve's control points and weights.
References axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::utilities::swap().
|
inline |
Evaluates a Bezier curve at a particular parameter value t.
| [in] | t | parameter value at which to evaluate |
References axom::utilities::annotations::end(), axom::primal::BezierCurve< T, NDIMS >::evaluate(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::utilities::lerp().
|
inline |
Computes the 0th and 1st derivative of a Bezier curve.
| [in] | t | Parameter value at which to compute tangent |
| [out] | eval | The value of the curve at t |
| [out] | Dt | The tangent vector of the curve at t |
References axom::utilities::annotations::end(), axom::primal::BezierCurve< T, NDIMS >::evaluateFirstDerivative(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::utilities::lerp().
|
inline |
Computes the tangent of a Bezier curve at a particular parameter value t.
| [in] | t | parameter value at which to compute tangent |
References axom::utilities::annotations::end(), axom::primal::BezierCurve< T, NDIMS >::evaluateFirstDerivative(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::utilities::lerp().
|
inline |
Computes the 0th, 1st, and 2nd derivatives of a Bezier curve.
| [in] | t | Parameter value at which to compute tangent |
| [out] | eval | The value of the curve at t |
| [out] | Dt | The tangent vector of the curve at t |
References axom::utilities::annotations::end(), axom::primal::BezierCurve< T, NDIMS >::evaluateSecondDerivative(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::utilities::lerp().
|
inline |
Computes the second derivative of a Bezier curve at a particular parameter value t.
| [in] | t | parameter value at which to compute tangent |
References axom::utilities::annotations::end(), axom::primal::BezierCurve< T, NDIMS >::evaluateSecondDerivative(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::utilities::lerp().
|
inline |
Splits a Bezier curve into two Bezier curves at a given parameter value.
| [in] | t | parameter value between 0 and 1 at which to evaluate |
| [out] | c1 | First output Bezier curve |
| [out] | c2 | Second output Bezier curve |
References axom::utilities::annotations::end(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::getWeight(), axom::primal::BezierCurve< T, NDIMS >::isRational(), axom::primal::Point< T, NDIMS >::lerp(), axom::utilities::lerp(), axom::primal::BezierCurve< T, NDIMS >::makeRational(), axom::primal::BezierCurve< T, NDIMS >::setOrder(), axom::primal::BezierCurve< T, NDIMS >::setWeight(), and SLIC_ASSERT.
|
inline |
Simple formatted print of a Bezier Curve instance.
| os | The output stream to write to |
References axom::primal::BezierCurve< T, NDIMS >::getOrder(), and axom::primal::BezierCurve< T, NDIMS >::isRational().
|
friend |
Checks equality of two Bezier Curve.
|
friend |