Easy3D 2.6.1
Loading...
Searching...
No Matches
SplineCurveInterpolation< Point, N, T > Class Template Reference

Cubic spline curve interpolation for arbitrary dimensions. More...

#include <easy3d/core/spline_curve_interpolation.h>

Public Types

enum  BoundaryType { first_deriv = 1 , second_deriv = 2 }
 The boundary type. More...
 
using Point_t = Point<N, T>
 The point type.
 

Public Member Functions

 SplineCurveInterpolation ()
 
void set_boundary (BoundaryType left, T left_value, BoundaryType right, T right_value)
 
void set_points (const std::vector< T > &parameters, const std::vector< Point_t > &points, bool cubic_spline=true)
 
void set_points (const std::vector< Point_t > &points, bool cubic_spline=true)
 This is an overload of the set_points() function. The parameters are the accumulated curve length.
 
Point< N, T > eval_f (T u) const
 

Detailed Description

template<template< size_t, class > class Point, size_t N, typename T>
class easy3d::SplineCurveInterpolation< Point, N, T >

Cubic spline curve interpolation for arbitrary dimensions.

This is a wrapper of SplineInterpolation. It can be instantiated with any point type (1D, 2D, 3D etc.).

Template Parameters
PointA 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.
NThe number of dimensions (e.g., 2 for 2D, 3 for 3D).
TThe scalar type (e.g., float or double).

Example usage:

const int resolution = 1000; // Number of line subdivisions to display the spline
interpolator.set_boundary(...);
interpolator.set_points(points);
for (int i = 0; i < resolution; ++i) {
const vec3 p = interpolator.eval_f(float(i) / float(resolution - 1));
std::cout << p << std::endl;
}
void set_boundary(BoundaryType left, T left_value, BoundaryType right, T right_value)
Definition spline_curve_interpolation.h:137
void set_points(const std::vector< T > &parameters, const std::vector< Point_t > &points, bool cubic_spline=true)
Definition spline_curve_interpolation.h:148
Point< N, T > eval_f(T u) const
Definition spline_curve_interpolation.h:218
SplineCurveInterpolation()
Definition spline_curve_interpolation.h:81
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
Examples
Tutorial_603_Curves/main.cpp.

Member Enumeration Documentation

◆ BoundaryType

template<template< size_t, class > class Point, size_t N, typename T>
enum BoundaryType

The boundary type.

Enumerator
first_deriv 

First derivative.

second_deriv 

Second derivative.

Constructor & Destructor Documentation

◆ SplineCurveInterpolation()

template<template< size_t, class > class Point, size_t N, typename T>
SplineCurveInterpolation ( )
inline

Constructor.

Sets default boundary conditions to be zero curvature at both ends.

Member Function Documentation

◆ eval_f()

template<template< size_t, class > class Point, size_t N, typename T>
Point< N, T > eval_f ( T u) const

Evaluates the position of the spline curve at a given parameter.

Parameters
uCurve parameter in the range [0, 1]. The actual meaning of the parameter is given by the parameters provided in set_points().

◆ set_boundary()

template<template< size_t, class > class Point, size_t N, typename T>
void set_boundary ( BoundaryType left,
T left_value,
BoundaryType right,
T right_value )

Sets the boundary condition (optional).

Attention
If called, it has to come before set_points().
Examples
Tutorial_603_Curves/main.cpp.

◆ set_points() [1/2]

template<template< size_t, class > class Point, size_t N, typename T>
void set_points ( const std::vector< Point_t > & points,
bool cubic_spline = true )

This is an overload of the set_points() function. The parameters are the accumulated curve length.

Sets the position of the point samples on the curve.

Parameters
pointsThe data points. The parameter of each point is its accumulated curve length from the first point.
cubic_splinetrue for cubic spline interpolation; false for linear interpolation.
Note
The points have to be ordered along the curve.

◆ set_points() [2/2]

template<template< size_t, class > class Point, size_t N, typename T>
void set_points ( const std::vector< T > & parameters,
const std::vector< Point_t > & points,
bool cubic_spline = true )

Sets the parameters and position of the point samples on the curve.

Parameters
parametersThe parameters (e.g., accumulated time or distance) of the points, each corresponding to a point in points.
pointsThe points. Each point corresponds to a parameter in parameters.
cubic_splinetrue for cubic spline interpolation; false for linear interpolation.
Note
The parameters have to be monotonously increasing along the curve.

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