|
| SplineCurveFitting (int k=2, Node_e node_type=eOPEN_UNIFORM) |
| Constructor.
|
|
void | set_ctrl_points (const std::vector< Point< N, T > > &points) |
| Sets the positions of the spline control points.
|
|
void | get_ctrl_points (std::vector< Point< N, T > > &points) const |
| Gets the control points of the spline.
|
|
void | set_node_type (Node_e type) |
| Sets the nodal vector type.
|
|
Point< N, T > | eval_f (T u) const |
| Evaluates position of the spline.
|
|
Point< N, T > | eval_df (T u) const |
| Evaluates speed of the spline.
|
|
int | get_order () const |
| Gets the order of the spline.
|
|
std::vector< T > | get_equally_spaced_parameters (std::size_t steps) const |
| Gets parameters such that evaluation of the curve positions using these parameters results in equally spaced points along the curve.
|
|
template<template< size_t, class > class Point, size_t N, typename T>
class easy3d::SplineCurveFitting< Point, N, T >
Spline curve fitting for arbitrary dimensions.
This class uses the efficient blossom algorithm to compute a position on the curve. It allows to set the order of the spline and the end points behavior (passing or not). The class can be instantiated with any point type (1D (float), 2D, 3D etc.) as long as the necessary operator overloads are implemented.
- Template Parameters
-
Point | A templated point class that supports basic arithmetic operations (addition and scalar multiplication). It must be parameterized as Point<N, T> , where N is the number of dimensions, and T is the data type. |
N | The number of dimensions (e.g., 2 for 2D, 3 for 3D). |
T | The scalar type (e.g., float or double ). |
Example usage:
const int resolution = 1000;
const int order = 3;
fitter.set_ctrl_points(points);
for(int i = 0; i < resolution; ++i) {
const vec3 p = fitter.eval_f(
float(i) /
float(resolution-1) );
std::cout << p << std::endl;
}
SplineCurveFitting(int k=2, Node_e node_type=eOPEN_UNIFORM)
Constructor.
Definition spline_curve_fitting.h:209
@ eOPEN_UNIFORM
Open uniform nodal vector.
Definition spline_curve_fitting.h:85
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
- Examples
- Tutorial_603_Curves/main.cpp.
template<template< size_t, class > class Point, size_t N, typename T>
The nodal vector (or knot vector) type.
In spline curve fitting, the nodal vector (or knot vector) plays a crucial role in defining how the spline curve is constructed. The type of nodal vector determines how the control points influence the shape of the curve.
- Uniform Knot Vector: A uniform knot vector means that the knot values are evenly spaced. This results in a B-spline where every segment between knots contributes equally to the overall curve. However, this type of knot vector does not guarantee that the curve passes through the first and last control points. Example of a uniform knot vector for a cubic B-spline (degree 3, 5 control points): t=[0,1,2,3,4,5,6].
- Open Uniform Knot Vector: An open uniform knot vector is a special type of uniform knot vector where the first and last knots are repeated degree + 1 times. This ensures that the curve starts at the first control point and ends at the last control point, making it more intuitive for curve fitting applications. Example of an open uniform knot vector for a cubic B-spline (degree 3, 5 control points): t=[0,0,0,0,1,2,3,3,3,3].
Enumerator |
---|
eUNIFORM | Uniform nodal vector.
|
eOPEN_UNIFORM | Open uniform nodal vector.
|
template<template< size_t, class > class Point, size_t N, typename T>
std::vector< T > get_equally_spaced_parameters |
( |
std::size_t | steps | ) |
const |
Gets parameters such that evaluation of the curve positions using these parameters results in equally spaced points along the curve.
- Parameters
-
steps | The number of steps. |
Calling eval_f() with equal intervals will result in non-uniformly distributed points on the curves. This method first evaluates the spline curve at equally spaced values in the parameter domain, and then does linear interpolation to compute the parameters that result in points uniformly spaced along the curve.
- Returns
- The parameters for equally spaced points along the curve.