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 | 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") | |
BezierCurve (int ord=-1) | |
Constructor for a Bezier Curve that reserves space for the given order of the curve. More... | |
BezierCurve (PointType *pts, int ord) | |
Constructor for a Bezier Curve from an array of coordinates. More... | |
BezierCurve (PointType *pts, T *weights, int ord) | |
Constructor for a Bezier Curve from an array of coordinates. More... | |
BezierCurve (const axom::Array< PointType > &pts, int ord) | |
Constructor for a Bezier Curve from an vector of coordinates. More... | |
BezierCurve (const axom::Array< PointType > &pts, const axom::Array< T > &weights, int ord) | |
Constructor for a Rational Bezier Curve from an vector of coordinates and weights. More... | |
void | setOrder (int ord) |
Sets the order of the Bezier Curve. More... | |
int | getOrder () const |
Returns the order of the Bezier Curve. More... | |
void | makeRational () |
Make trivially rational. If already rational, do nothing. More... | |
void | makeNonrational () |
Make nonrational by shrinking array of weights. More... | |
bool | isRational () const |
Use array size as flag for rationality. More... | |
void | clear () |
Clears the list of control points, make nonrational. More... | |
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 T & | getWeight (int idx) const |
Get a specific weight. More... | |
void | setWeight (int idx, T weight) |
Set the weight at a specific index. More... | |
CoordsVec | getControlPoints () const |
Returns a copy of the Bezier curve's control points. More... | |
WeightsVec | getWeights () const |
Returns a copy of the Bezier curve's weights. More... | |
void | reverseOrientation () |
Reverses the order of the Bezier curve's control points and 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... | |
PointType | evaluate (T t) const |
Evaluates a Bezier curve at a particular parameter value t. More... | |
void | evaluate_first_derivative (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 | evaluate_second_derivative (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... | |
void | split (T t, BezierCurve &c1, BezierCurve &c2) const |
Splits a Bezier curve into two Bezier curves at a given parameter value. More... | |
bool | isLinear (double tol=1E-8) const |
Predicate to check if the Bezier curve is approximately linear. More... | |
std::ostream & | print (std::ostream &os) const |
Simple formatted print of a Bezier Curve instance. 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 >::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> |
|
inlineexplicit |
Constructor for a Bezier Curve that reserves space for the given order of the curve.
[in] | order | the order of the resulting Bezier curve |
References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.
|
inline |
Constructor for a Bezier Curve from an array of coordinates.
[in] | pts | a vector with ord+1 control points |
[in] | ord | The Curve's polynomial order |
References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.
|
inline |
Constructor for a Bezier Curve from an array of coordinates.
[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 |
References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.
|
inline |
Constructor for a Bezier Curve from an vector of coordinates.
[in] | pts | a vector with ord+1 control points |
[in] | ord | The Curve's polynomial order |
References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.
|
inline |
Constructor for a Rational Bezier Curve from an vector 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 |
References axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), axom::Array< T, DIM, SPACE >::size(), and SLIC_ASSERT.
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(), and axom::Array< T, DIM, SPACE >::resize().
|
inline |
Returns the order of the Bezier Curve.
References axom::Array< T, DIM, SPACE >::size().
|
inline |
Make trivially rational. If already rational, do nothing.
References axom::Array< T, DIM, SPACE >::fill(), axom::primal::BezierCurve< T, NDIMS >::getOrder(), axom::primal::BezierCurve< T, NDIMS >::isRational(), and axom::Array< T, DIM, SPACE >::resize().
|
inline |
Make nonrational by shrinking array of weights.
References axom::Array< T, DIM, SPACE >::resize().
|
inline |
Use array size as flag for rationality.
References axom::Array< T, DIM, SPACE >::empty().
|
inline |
Clears the list of control points, make nonrational.
References axom::Array< T, DIM, SPACE >::clear(), and axom::primal::BezierCurve< T, NDIMS >::makeNonrational().
|
inline |
Retrieves the control point at index idx.
|
inline |
Retrieves the control point at index idx.
|
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 copy of the Bezier curve's control points.
|
inline |
Returns a copy of the Bezier curve's weights.
|
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 |
Returns an axis-aligned bounding box containing the Bezier curve.
References axom::Array< T, DIM, SPACE >::data(), and axom::Array< T, DIM, SPACE >::size().
|
inline |
Returns an oriented bounding box containing the Bezier curve.
References axom::Array< T, DIM, SPACE >::data(), and axom::Array< T, DIM, SPACE >::size().
|
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 >::evaluate_first_derivative(), 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 >::evaluate_first_derivative(), 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 >::evaluate_second_derivative(), 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 >::evaluate_second_derivative(), 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 |
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 |
References axom::primal::BezierCurve< T, NDIMS >::getOrder(), and axom::primal::squared_distance().
|
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 |