opensurgsim
Namespaces | Functions
CardinalSplines.h File Reference

collects the utilities to do Cardinal Splines interpolation. More...

#include <vector>
#include "SurgSim/DataStructures/Vertices.h"
#include "SurgSim/Math/Vector.h"

Go to the source code of this file.

Namespaces

 SurgSim
 Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui needs glew but we need to call glewInit() from a osg callback, using this call we avoid getting warnings about redefinitions.
 

Functions

void SurgSim::Math::CardinalSplines::extendControlPoints (const SurgSim::DataStructures::VerticesPlain &points, std::vector< SurgSim::Math::Vector3d > *result)
 Function to add two 'ghost' points to 'points' at the beginning and the end, prepare 'points' for Cardinal Splines interpolation. More...
 
void SurgSim::Math::CardinalSplines::interpolate (size_t subdivisions, const std::vector< Math::Vector3d > &controlPoints, std::vector< Math::Vector3d > *points, double tau=0.4)
 Run Cardinal Splines interpolation on 'controlPoints'. More...
 

Detailed Description

collects the utilities to do Cardinal Splines interpolation.

Function Documentation

§ extendControlPoints()

void SurgSim::Math::CardinalSplines::extendControlPoints ( const SurgSim::DataStructures::VerticesPlain points,
std::vector< SurgSim::Math::Vector3d > *  result 
)

Function to add two 'ghost' points to 'points' at the beginning and the end, prepare 'points' for Cardinal Splines interpolation.

Parameters
pointsList of points to be interpolated.
[out]resultList of points with two ghost points added, one at the beginning and another at the end of 'points'.

§ interpolate()

void SurgSim::Math::CardinalSplines::interpolate ( size_t  subdivisions,
const std::vector< Math::Vector3d > &  controlPoints,
std::vector< Math::Vector3d > *  points,
double  tau = 0.4 
)

Run Cardinal Splines interpolation on 'controlPoints'.

See https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline https://en.wikipedia.org/wiki/Cubic_Hermite_spline https://people.cs.clemson.edu/~dhouse/courses/405/notes/splines.pdf https://www.cs.utexas.edu/~fussell/courses/cs384g/lectures/lecture16-Interpolating_curves.pdf for more details.

Parameters
subdivisionsNumber of interpolated points between each pair of control points.
controlPointsList of points to be interpolated.
[out]pointsList of interpolated points, not including the control points.
tauDefines the tension, affects how sharply the curve bends at the control points.