#include <bSpline.h>
Public Member Functions | |
BSpline (size_t order=2, bool isPeriodic=true) | |
This constructor builds a BSpline instance of unspecified length. | |
BSpline (const BSpline &other) | |
The copy constructor does a deep copy. | |
double | getMaximumSValue () |
This member function returns the maximum value for the spline parameter S. | |
double | getMinimumSValue () |
This member function returns the minimum value for the spline parameter S. | |
void | setControlPoints (const std::vector< Type > &controlPoints) |
This member function sets the values of the control points of the spline. | |
void | setKnotMultiplicities (const std::vector< size_t > &knotMultiplicities) |
This member function sets the knot multiplicity at each node of the spline. | |
void | setNumberOfNodes (size_t numberOfNodes, bool setKnotMultiplicitiesFlag=true) |
This member function both specifies the number of nodes in the spline and sets the node positions so that the spline is "uniform". | |
void | setNumberOfNodes (size_t numberOfNodes, const std::vector< double > &nodePositions, bool setKnotMultiplicitiesFlag=true) |
This member function specifies the number of nodes in the spline and allows the user to set the position of each node. | |
BSpline< Type > & | operator= (const BSpline< Type > &other) |
The assigment operator does a deep copy. | |
Type | operator() (double sValue) |
This operator evaluates the spline at the specified value of spline parameter s. | |
Protected Member Functions | |
Polynomial< double > | computeBasisFunction (size_t order, size_t spanNumber, size_t componentNumber, const Array1D< size_t > &cumulativeKnotCounts, const Array1D< double > &knotPositions) |
This protected member function computes one spline basis function for use in calculating spline values. | |
Array1D< Array1D< double > > | getControlPointVectors (size_t order, size_t numberOfNodes, const Array1D< size_t > &cumulativeKnotCounts, const std::vector< Type > &controlPoints) |
This protected member function returns an array in which each element corresponds to one span of the spline, and contains the control-point values that affect the spline values within that span. | |
Array1D< Array2D< double > > | getCoefficientMatrices (size_t order, size_t numberOfNodes, const Array1D< double > &nodePositions, const Array1D< double > &knotPositions, const Array1D< size_t > &cumulativeKnotCounts) |
This protected member function returns an array in which each element corresponds to one span of the spline, and contains a matrix of the polynomial coefficients of the basis functions that affect the spline values within that span. | |
double | getKnotPosition (int knotNumber, const Array1D< double > &knotPositions) |
This protected member function wraps argument knotNumber so that it is in the range [0, knotPositions.size() - 1], and then returns the corresponding value from knotPositions. | |
size_t | getSpanNumber (double sValue) |
This protected member function returns the number of the span in which the specified spline parameter value lies. | |
void | setNodePositions (const std::vector< double > &nodePositions) |
This protected member function sets the positions of the nodes in the spline. | |
Protected Attributes | |
Array1D< Array2D< double > > | m_coefficientMatrixArray |
std::vector< Type > | m_controlPoints |
Array1D< Array1D< Type > > | m_controlPointVectorArray |
Array1D< size_t > | m_cumulativeKnotCounts |
Array1D< double > | m_inputVector |
bool | m_isPeriodic |
bool | m_isUniform |
Array1D< double > | m_knotPositionArray |
Array1D< double > | m_nodePositionArray |
size_t | m_numberOfNodes |
size_t | m_order |
size_t | m_orderPlusOne |
It may contain bugs.
This class template implements a B-spline of arbitrary order. It is templated on control point type so that you can, for example, create a spline with 2D or 3D values by by specifying control points of type Vector2D or Vector3D. Note that the splines represented by this class are all 1D in the sense that you can represent them using a parametric function of one parameter. If you set the template parameter to be Vector2D, then you wind up with a function that converts this 1D input parameter into 2D output values. If you want a spline that has two input parameters, perhaps to represent a surface, then you need to use the similar, but more restrictive, BSpline2D class. The BSpline class supports both periodic and non-periodic splines, supports both uniform and non-uniform node spacing, and supports multiple knots at each node to allow corners and discontinuities.
Definition at line 48 of file bSpline.h.
dlr::numeric::BSpline< Type >::BSpline | ( | size_t | order = 2 , |
|
bool | isPeriodic = true | |||
) | [inline] |
This constructor builds a BSpline instance of unspecified length.
order | This argument sets the order of the spline. For a quadratic spline, set order to 2. For a cubic spline, set order to 3. | |
isPeriodic | If this argument is true, the spline will be periodic. That is, its last node will overlap its first, and the spline parameter will wrap around from its maximum value back to zero. |
dlr::numeric::BSpline< Type >::BSpline | ( | const BSpline< Type > & | other | ) | [inline] |
Polynomial< double > dlr::numeric::BSpline< Type >::computeBasisFunction | ( | size_t | order, | |
size_t | spanNumber, | |||
size_t | componentNumber, | |||
const Array1D< size_t > & | cumulativeKnotCounts, | |||
const Array1D< double > & | knotPositions | |||
) | [inline, protected] |
This protected member function computes one spline basis function for use in calculating spline values.
order | This argument specifies the order of the spline (2 for quadratic, 3 for cubic, etc.) | |
spanNumber | This argument specifies the span for which the basis function is being computed. | |
componentNumber | This argument specifies which of the (order + 1) basis functions that overlap the span is to be computed. | |
cumulativeKnotCounts | This argument specifies, for each node, the total number of knots at that node plus the total number of knots at preceding nodes. | |
knotPositions | This argument specifies the position (spline parameter) of each knot. If the spline contains nodes with multiple knots, then the argument will contain consecutive entries with the same value. |
Definition at line 694 of file bSpline.h.
References dlr::numeric::BSpline< Type >::getKnotPosition(), and dlr::numeric::Array1D< Type >::size().
Referenced by dlr::numeric::BSpline< Type >::getCoefficientMatrices().
Array1D< Array2D< double > > dlr::numeric::BSpline< Type >::getCoefficientMatrices | ( | size_t | order, | |
size_t | numberOfNodes, | |||
const Array1D< double > & | nodePositions, | |||
const Array1D< double > & | knotPositions, | |||
const Array1D< size_t > & | cumulativeKnotCounts | |||
) | [inline, protected] |
This protected member function returns an array in which each element corresponds to one span of the spline, and contains a matrix of the polynomial coefficients of the basis functions that affect the spline values within that span.
This function is used to allow efficient calculation of spline values.
order | This argument is the order of the spline. | |
numberOfNodes | This argument specifies the number of nodes in the spline. | |
nodePositions | This argument specifies the positions of each node in the spline. Positions are defined in terms of spline parameter s. | |
knotPositions | This argument specifies the positions of each knot in the spline. Each knot has the same position as the node with which it is associated. Positions are defined in terms of spline parameter s. | |
cumulativeKnotCounts | This argument specifies, for each node, the total number of knots at that node plus the total number of knots at preceding nodes. |
Definition at line 780 of file bSpline.h.
References dlr::numeric::BSpline< Type >::computeBasisFunction(), dlr::numeric::Array1D< Type >::copy(), dlr::numeric::Polynomial< Type >::getCoefficientArray(), and dlr::numeric::Polynomial< Type >::getOrder().
Referenced by dlr::numeric::BSpline< Type >::setKnotMultiplicities().
Array1D< Array1D< double > > dlr::numeric::BSpline< Type >::getControlPointVectors | ( | size_t | order, | |
size_t | numberOfNodes, | |||
const Array1D< size_t > & | cumulativeKnotCounts, | |||
const std::vector< Type > & | controlPoints | |||
) | [inline, protected] |
This protected member function returns an array in which each element corresponds to one span of the spline, and contains the control-point values that affect the spline values within that span.
This function is used to allow efficient calculation of spline values.
order | This argument is the order of the spline. | |
numberOfNodes | This argument specifies the number of nodes in the spline. | |
cumulativeKnotCounts | This argument specifies, for each node, the total number of knots at that node plus the total number of knots at preceding nodes. | |
controlPoints | This argument specifies the actual control point values. |
Definition at line 816 of file bSpline.h.
References dlr::numeric::Array1D< Type >::size().
Referenced by dlr::numeric::BSpline< Type >::setControlPoints().
double dlr::numeric::BSpline< Type >::getKnotPosition | ( | int | knotNumber, | |
const Array1D< double > & | knotPositions | |||
) | [inline, protected] |
This protected member function wraps argument knotNumber so that it is in the range [0, knotPositions.size() - 1], and then returns the corresponding value from knotPositions.
knotNumber | This argument is the number of the knot, possibly out-of-range and needing to be wrapped. | |
knotPositions | This argument is an array of knot positions. |
Definition at line 860 of file bSpline.h.
References dlr::numeric::Array1D< Type >::size().
Referenced by dlr::numeric::BSpline< Type >::computeBasisFunction().
double dlr::numeric::BSpline< Type >::getMaximumSValue | ( | ) | [inline] |
This member function returns the maximum value for the spline parameter S.
For a non-periodic spline, calling operator()(double) with an argument greater than or equal to the result of getMaximumSValue() is an error. For a periodic spline, calling operator()(double) with an argument greater than or equal to the result of getMaximumSValue() is not an error, but the parameter will be wrapped around to the beginning of the spline.
Definition at line 459 of file bSpline.h.
References dlr::numeric::Array1D< Type >::size().
double dlr::numeric::BSpline< Type >::getMinimumSValue | ( | ) | [inline] |
This member function returns the minimum value for the spline parameter S.
For a non-periodic spline, calling operator()(double) with an argument less than the result of getMinimumSValue() is an error. For a periodic spline, calling operator()(double) with an argument less than the result of getMinimumSValue() is not an error, but the parameter will be wrapped around to the end of the spline.
Definition at line 475 of file bSpline.h.
References dlr::numeric::Array1D< Type >::size().
size_t dlr::numeric::BSpline< Type >::getSpanNumber | ( | double | sValue | ) | [inline, protected] |
This protected member function returns the number of the span in which the specified spline parameter value lies.
sValue | This argument indicates the point of interest along the spline. |
Definition at line 885 of file bSpline.h.
References dlr::numeric::Array1D< Type >::begin(), and dlr::numeric::Array1D< Type >::end().
Referenced by dlr::numeric::BSpline< Type >::operator()().
Type dlr::numeric::BSpline< Type >::operator() | ( | double | sValue | ) | [inline] |
This operator evaluates the spline at the specified value of spline parameter s.
Definition at line 658 of file bSpline.h.
References dlr::numeric::BSpline< Type >::getSpanNumber(), dlr::numeric::Array2D< Type >::row(), and dlr::numeric::Array1D< Type >::size().
BSpline< Type > & dlr::numeric::BSpline< Type >::operator= | ( | const BSpline< Type > & | other | ) | [inline] |
The assigment operator does a deep copy.
other | This argument is the BSpline instance to be copied. |
Definition at line 634 of file bSpline.h.
References dlr::numeric::Array1D< Type >::copy(), dlr::numeric::BSpline< Type >::m_coefficientMatrixArray, dlr::numeric::BSpline< Type >::m_controlPoints, dlr::numeric::BSpline< Type >::m_controlPointVectorArray, dlr::numeric::BSpline< Type >::m_cumulativeKnotCounts, dlr::numeric::BSpline< Type >::m_inputVector, dlr::numeric::BSpline< Type >::m_knotPositionArray, dlr::numeric::BSpline< Type >::m_nodePositionArray, dlr::numeric::BSpline< Type >::m_numberOfNodes, and dlr::numeric::BSpline< Type >::m_order.
void dlr::numeric::BSpline< Type >::setControlPoints | ( | const std::vector< Type > & | controlPoints | ) | [inline] |
This member function sets the values of the control points of the spline.
If the spline is periodic, then the value of the final control point should be omitted; it will be automatically copied from the value of the first control point.
controlPoints | This argument specifies the control point values for the spline. |
Definition at line 491 of file bSpline.h.
References dlr::numeric::BSpline< Type >::getControlPointVectors(), and dlr::numeric::Array1D< Type >::size().
void dlr::numeric::BSpline< Type >::setKnotMultiplicities | ( | const std::vector< size_t > & | knotMultiplicities | ) | [inline] |
This member function sets the knot multiplicity at each node of the spline.
Setting the knot multiplicity of a node to N will introduce, at that node, a discontinuity in the ((order
knotMultiplicities | This argument specifies the knot multipicity at each node in the spline. For a periodic spline, the first and last nodes overlap, and must have the same knot multiplicity. For a non-periodic spline, the first and last nodes must have knot multiplicity equal to (order + 1). |
Definition at line 532 of file bSpline.h.
References dlr::numeric::Array1D< Type >::begin(), dlr::numeric::BSpline< Type >::getCoefficientMatrices(), dlr::numeric::Array1D< Type >::reinit(), and dlr::numeric::Array1D< Type >::size().
Referenced by dlr::numeric::BSpline< Type >::setNumberOfNodes().
void dlr::numeric::BSpline< Type >::setNodePositions | ( | const std::vector< double > & | nodePositions | ) | [inline, protected] |
This protected member function sets the positions of the nodes in the spline.
nodePositions | This argument is a vector of node positions. |
Definition at line 935 of file bSpline.h.
References dlr::numeric::Array1D< Type >::begin(), dlr::numeric::Array1D< Type >::reinit(), and dlr::numeric::Array1D< Type >::size().
Referenced by dlr::numeric::BSpline< Type >::setNumberOfNodes().
void dlr::numeric::BSpline< Type >::setNumberOfNodes | ( | size_t | numberOfNodes, | |
const std::vector< double > & | nodePositions, | |||
bool | setKnotMultiplicitiesFlag = true | |||
) | [inline] |
This member function specifies the number of nodes in the spline and allows the user to set the position of each node.
The node position values must be monotonically increasing with node number. For periodic splines, the first and last node overlap, and represent the same control point, however different values should be specified for the positions of the first and last nodes. When the spline parameter, s, reaches the position of the final node, it will be wrapped around, as if it were actually set to the position of the first node. For both periodic and non-periodic splines, the number of spans will be equal to numberOfNodes - 1.
numberOfNodes | This argument specifies how many nodes the spline should have. For periodic splines, the first and last nodes represent the same physical point on the spline. | |
nodePositions | This argument specifies the positions (in spline parameter space) of the nodes. This argument can be used to create non-uniform splines. | |
setKnotMultiplicitiesFlag | This argument is used to avoid redundant calculations if the knot multiplicities will be explicitly set later. If this argument is set to true, the knot multiplicity of each node will be set to the default value. The default value is 1 for each node except the first and last nodes of a non-periodic spline, for which the default knot multiplicity is (order + 1). If this argument is set to false, the knot multiplicities will not be set, and the calling context must explicitly set them by calling member function setKnotMultiplicities(). |
Definition at line 612 of file bSpline.h.
References dlr::numeric::BSpline< Type >::setKnotMultiplicities(), and dlr::numeric::BSpline< Type >::setNodePositions().
void dlr::numeric::BSpline< Type >::setNumberOfNodes | ( | size_t | numberOfNodes, | |
bool | setKnotMultiplicitiesFlag = true | |||
) | [inline] |
This member function both specifies the number of nodes in the spline and sets the node positions so that the spline is "uniform".
The node positions will be set so that the first node lies at spline parameter s = 0.0, the second node lies at s = 1.0, the third at s = 2.0, and so on. For periodic splines, the first and last node overlap, and represent the same control point. For both periodic and non-periodic splines, the number of spans will be equal to numberOfNodes - 1.
numberOfNodes | This argument specifies how many nodes the spline should have. For periodic splines, the first and last nodes represent the same physical point on the spline. | |
setKnotMultiplicitiesFlag | This argument is used to avoid redundant calculations if the knot multiplicities will be explicitly set later. If this argument is set to true, the knot multiplicity of each node will be set to the default value. The default value is 1 for each node except the first and last nodes of a non-periodic spline, for which the default knot multiplicity is (order + 1). If this argument is set to false, the knot multiplicities will not be set, and the calling context must explicitly set them by calling member function setKnotMultiplicities(). |