Easy3D 2.5.3
SplineCurveFitting< Point_t > Class Template Reference

Spline curve fitting for arbitrary dimensions. More...

#include <easy3d/core/spline_curve_fitting.h>

Public Types

enum  Node_e { eUNIFORM , eOPEN_UNIFORM }
 
typedef Point_t::FT FT
 

Public Member Functions

 SplineCurveFitting (int k=2, Node_e node_type=eOPEN_UNIFORM)
 Constructor. More...
 
void set_ctrl_points (const std::vector< Point_t > &point)
 Sets the position of the spline control points.
 
void get_ctrl_points (std::vector< Point_t > &points) const
 Gets the control points of the spline.
 
void set_node_type (Node_e type)
 Sets the the nodal vector type. More...
 
Point_t eval_f (FT u) const
 Evaluates position of the spline. More...
 
Point_t eval_df (FT u) const
 Evaluates speed of the spline.
 
int get_order () const
 
std::vector< FT > 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. More...
 

Detailed Description

template<typename Point_t>
class easy3d::SplineCurveFitting< Point_t >

Spline curve fitting for arbitrary dimensions.

This class uses the efficient blossom algorithm to compute a position on the curve. It allow 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_ttype of a point operators such as '+' '*' must be correctly overloaded. The default constructor must be defined to return the null vector (0, 0 ,0 ...)
FTfloating point representation of the points (float, double etc.) Example usage:
const int resolution = 1000; // Number of line subdivisions to display the spline
const int order = 3; // Smoothness of the spline (min 2)
SplineCurveFitting<vec3> fitter(order, SplineCurveFitting<vec3>::eOPEN_UNIFORM);
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;
}
@ eOPEN_UNIFORM
Connected to the first and last control points.
Definition: spline_curve_fitting.h:66
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition: types.h:45

Member Enumeration Documentation

◆ Node_e

enum Node_e
Enumerator
eOPEN_UNIFORM 

Connected to the first and last control points.

Constructor & Destructor Documentation

◆ SplineCurveFitting()

SplineCurveFitting ( int  k = 2,
Node_e  node_type = eOPEN_UNIFORM 
)
explicit

Constructor.

Parameters
kOrder of the spline (minimum is two)
node_typeNodal vector type (uniform, open_uniform). This will define the behavior of the spline with its control points as well as its speed according to its parameter.

Member Function Documentation

◆ eval_f()

Point_t eval_f ( FT  u) const

Evaluates position of the spline.

Parameters
u: curve parameter ranging from [0; 1].
Note
Calling this with equally distributed u will result in non-uniformly distributed points on the curves (because some of input points are closely spaced but others may not). To get points at fixed distances along the curve, use the parameter generated from get_equally_spaced_parameters().

◆ get_equally_spaced_parameters()

std::vector< typename Point_t::FT > 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.

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.

◆ set_node_type()

void set_node_type ( Node_e  type)

Sets the the nodal vector type.

The the nodal vector type.


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