AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::primal::BezierCurve< T, NDIMS > Class Template Reference

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...
 
PointTypeoperator[] (int idx)
 Retrieves the control point at index idx. More...
 
const PointTypeoperator[] (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)
 

Detailed Description

template<typename T, int NDIMS>
class axom::primal::BezierCurve< T, NDIMS >

Represents a Bezier curve defined by an array of control points.

Template Parameters
Tthe coordinate type, e.g., double, float, etc.
NDIMSthe 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,

Member Typedef Documentation

◆ PointType

template<typename T , int NDIMS>
using axom::primal::BezierCurve< T, NDIMS >::PointType = Point<T, NDIMS>

◆ VectorType

template<typename T , int NDIMS>
using axom::primal::BezierCurve< T, NDIMS >::VectorType = Vector<T, NDIMS>

◆ SegmentType

template<typename T , int NDIMS>
using axom::primal::BezierCurve< T, NDIMS >::SegmentType = Segment<T, NDIMS>

◆ WeightsVec

template<typename T , int NDIMS>
using axom::primal::BezierCurve< T, NDIMS >::WeightsVec = axom::Array<T>

◆ CoordsVec

template<typename T , int NDIMS>
using axom::primal::BezierCurve< T, NDIMS >::CoordsVec = axom::Array<PointType>

◆ BoundingBoxType

template<typename T , int NDIMS>
using axom::primal::BezierCurve< T, NDIMS >::BoundingBoxType = BoundingBox<T, NDIMS>

◆ OrientedBoundingBoxType

template<typename T , int NDIMS>
using axom::primal::BezierCurve< T, NDIMS >::OrientedBoundingBoxType = OrientedBoundingBox<T, NDIMS>

Constructor & Destructor Documentation

◆ BezierCurve() [1/5]

template<typename T , int NDIMS>
axom::primal::BezierCurve< T, NDIMS >::BezierCurve ( int  ord = -1)
inlineexplicit

Constructor for a Bezier Curve that reserves space for the given order of the curve.

Parameters
[in]orderthe order of the resulting Bezier curve
Precondition
order is greater than or equal to -1.

References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.

◆ BezierCurve() [2/5]

template<typename T , int NDIMS>
axom::primal::BezierCurve< T, NDIMS >::BezierCurve ( PointType pts,
int  ord 
)
inline

Constructor for a Bezier Curve from an array of coordinates.

Parameters
[in]ptsa vector with ord+1 control points
[in]ordThe Curve's polynomial order
Precondition
order is greater than or equal to zero

References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.

◆ BezierCurve() [3/5]

template<typename T , int NDIMS>
axom::primal::BezierCurve< T, NDIMS >::BezierCurve ( PointType pts,
T *  weights,
int  ord 
)
inline

Constructor for a Bezier Curve from an array of coordinates.

Parameters
[in]ptsa vector with ord+1 control points
[in]weightsa vector with ord+1 positive weights
[in]ordThe Curve's polynomial order
Precondition
order is greater than or equal to zero

References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.

◆ BezierCurve() [4/5]

template<typename T , int NDIMS>
axom::primal::BezierCurve< T, NDIMS >::BezierCurve ( const axom::Array< PointType > &  pts,
int  ord 
)
inline

Constructor for a Bezier Curve from an vector of coordinates.

Parameters
[in]ptsa vector with ord+1 control points
[in]ordThe Curve's polynomial order
Precondition
order is greater than or equal to zero

References axom::primal::BezierCurve< T, NDIMS >::makeNonrational(), axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), and SLIC_ASSERT.

◆ BezierCurve() [5/5]

template<typename T , int NDIMS>
axom::primal::BezierCurve< T, NDIMS >::BezierCurve ( const axom::Array< PointType > &  pts,
const axom::Array< T > &  weights,
int  ord 
)
inline

Constructor for a Rational Bezier Curve from an vector of coordinates and weights.

Parameters
[in]ptsa vector with ord+1 control points
[in]weightsa vector with ord+1 positive weights
[in]ordThe Curve's polynomial order
Precondition
order is greater than or equal to zero

References axom::utilities::max(), axom::Array< T, DIM, SPACE >::resize(), axom::Array< T, DIM, SPACE >::size(), and SLIC_ASSERT.

Member Function Documentation

◆ AXOM_STATIC_ASSERT_MSG() [1/2]

template<typename T , int NDIMS>
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_STATIC_ASSERT_MSG() [2/2]

template<typename T , int NDIMS>
axom::primal::BezierCurve< T, NDIMS >::AXOM_STATIC_ASSERT_MSG ( std::is_arithmetic< T >::value  ,
"A Bezier Curve must be defined using an arithmetic type"   
)

◆ setOrder()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::setOrder ( int  ord)
inline

◆ getOrder()

template<typename T , int NDIMS>
int axom::primal::BezierCurve< T, NDIMS >::getOrder ( ) const
inline

Returns the order of the Bezier Curve.

References axom::Array< T, DIM, SPACE >::size().

◆ makeRational()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::makeRational ( )
inline

◆ makeNonrational()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::makeNonrational ( )
inline

Make nonrational by shrinking array of weights.

References axom::Array< T, DIM, SPACE >::resize().

◆ isRational()

template<typename T , int NDIMS>
bool axom::primal::BezierCurve< T, NDIMS >::isRational ( ) const
inline

Use array size as flag for rationality.

References axom::Array< T, DIM, SPACE >::empty().

◆ clear()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::clear ( )
inline

Clears the list of control points, make nonrational.

References axom::Array< T, DIM, SPACE >::clear(), and axom::primal::BezierCurve< T, NDIMS >::makeNonrational().

◆ operator[]() [1/2]

template<typename T , int NDIMS>
PointType& axom::primal::BezierCurve< T, NDIMS >::operator[] ( int  idx)
inline

Retrieves the control point at index idx.

◆ operator[]() [2/2]

template<typename T , int NDIMS>
const PointType& axom::primal::BezierCurve< T, NDIMS >::operator[] ( int  idx) const
inline

Retrieves the control point at index idx.

◆ getWeight()

template<typename T , int NDIMS>
const T& axom::primal::BezierCurve< T, NDIMS >::getWeight ( int  idx) const
inline

Get a specific weight.

Parameters
[in]idxThe index of the weight
Precondition
Requires that the curve be rational

References axom::primal::BezierCurve< T, NDIMS >::isRational(), and SLIC_ASSERT.

◆ setWeight()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::setWeight ( int  idx,
weight 
)
inline

Set the weight at a specific index.

Parameters
[in]idxThe index of the weight
[in]weightThe updated value of the weight
Precondition
Requires that the curve be rational
Requires that the weight be positive

References axom::primal::BezierCurve< T, NDIMS >::isRational(), and SLIC_ASSERT.

◆ getControlPoints()

template<typename T , int NDIMS>
CoordsVec axom::primal::BezierCurve< T, NDIMS >::getControlPoints ( ) const
inline

Returns a copy of the Bezier curve's control points.

◆ getWeights()

template<typename T , int NDIMS>
WeightsVec axom::primal::BezierCurve< T, NDIMS >::getWeights ( ) const
inline

Returns a copy of the Bezier curve's weights.

◆ reverseOrientation()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::reverseOrientation ( )
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().

◆ boundingBox()

template<typename T , int NDIMS>
BoundingBoxType axom::primal::BezierCurve< T, NDIMS >::boundingBox ( ) const
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().

◆ orientedBoundingBox()

template<typename T , int NDIMS>
OrientedBoundingBoxType axom::primal::BezierCurve< T, NDIMS >::orientedBoundingBox ( ) const
inline

Returns an oriented bounding box containing the Bezier curve.

References axom::Array< T, DIM, SPACE >::data(), and axom::Array< T, DIM, SPACE >::size().

◆ evaluate()

template<typename T , int NDIMS>
PointType axom::primal::BezierCurve< T, NDIMS >::evaluate ( t) const
inline

Evaluates a Bezier curve at a particular parameter value t.

Parameters
[in]tparameter value at which to evaluate
Returns
p the value of the Bezier curve at t
Note
We typically evaluate the curve at t between 0 and 1

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().

◆ evaluate_first_derivative()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::evaluate_first_derivative ( t,
PointType eval,
VectorType Dt 
) const
inline

Computes the 0th and 1st derivative of a Bezier curve.

Parameters
[in]tParameter value at which to compute tangent
[out]evalThe value of the curve at t
[out]DtThe 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().

◆ dt()

template<typename T , int NDIMS>
VectorType axom::primal::BezierCurve< T, NDIMS >::dt ( t) const
inline

Computes the tangent of a Bezier curve at a particular parameter value t.

Parameters
[in]tparameter value at which to compute tangent
Returns
p the tangent vector of the Bezier curve at t
Note
We typically find the tangent of the curve at t between 0 and 1

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().

◆ evaluate_second_derivative()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::evaluate_second_derivative ( t,
PointType eval,
VectorType Dt,
VectorType DtDt 
) const
inline

Computes the 0th, 1st, and 2nd derivatives of a Bezier curve.

Parameters
[in]tParameter value at which to compute tangent
[out]evalThe value of the curve at t
[out]DtThe 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().

◆ dtdt()

template<typename T , int NDIMS>
VectorType axom::primal::BezierCurve< T, NDIMS >::dtdt ( t) const
inline

Computes the second derivative of a Bezier curve at a particular parameter value t.

Parameters
[in]tparameter value at which to compute tangent
Returns
p the 2nd derivative vector of the Bezier curve at t
Note
We typically find the second derivative of the curve at t between 0 and 1

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().

◆ split()

template<typename T , int NDIMS>
void axom::primal::BezierCurve< T, NDIMS >::split ( t,
BezierCurve< T, NDIMS > &  c1,
BezierCurve< T, NDIMS > &  c2 
) const
inline

Splits a Bezier curve into two Bezier curves at a given parameter value.

Parameters
[in]tparameter value between 0 and 1 at which to evaluate
[out]c1First output Bezier curve
[out]c2Second output Bezier curve
Precondition
Parameter t must be between 0 and 1

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.

◆ isLinear()

template<typename T , int NDIMS>
bool axom::primal::BezierCurve< T, NDIMS >::isLinear ( double  tol = 1E-8) const
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

Parameters
[in]tolThreshold for sum of squared distances
Returns
True if c1 is near-linear

References axom::primal::BezierCurve< T, NDIMS >::getOrder(), and axom::primal::squared_distance().

◆ print()

template<typename T , int NDIMS>
std::ostream& axom::primal::BezierCurve< T, NDIMS >::print ( std::ostream &  os) const
inline

Simple formatted print of a Bezier Curve instance.

Parameters
osThe output stream to write to
Returns
A reference to the modified ostream

References axom::primal::BezierCurve< T, NDIMS >::getOrder(), and axom::primal::BezierCurve< T, NDIMS >::isRational().

Friends And Related Function Documentation

◆ operator==

template<typename T , int NDIMS>
bool operator== ( const BezierCurve< T, NDIMS > &  lhs,
const BezierCurve< T, NDIMS > &  rhs 
)
friend

Checks equality of two Bezier Curve.

◆ operator!=

template<typename T , int NDIMS>
bool operator!= ( const BezierCurve< T, NDIMS > &  lhs,
const BezierCurve< T, NDIMS > &  rhs 
)
friend

The documentation for this class was generated from the following file: