32 #ifndef CatmullRomInterpolator_INCLUDE_ONCE 33 #define CatmullRomInterpolator_INCLUDE_ONCE 53 VL_DEBUG_SET_OBJECT_NAME()
77 T a = mCatmullRomSpline[0];
78 T b = mCatmullRomSpline[1];
79 T d = mCatmullRomSpline[mCatmullRomSpline.size()-1];
81 mCatmullRomSpline.insert(mCatmullRomSpline.begin(),d);
82 mCatmullRomSpline.push_back(a);
83 mCatmullRomSpline.push_back(b);
87 T a = mCatmullRomSpline[0] + (mCatmullRomSpline[0] - mCatmullRomSpline[1]);
88 T b = mCatmullRomSpline[mCatmullRomSpline.size()-1] + (mCatmullRomSpline[mCatmullRomSpline.size()-1] - mCatmullRomSpline[mCatmullRomSpline.size()-2]);
89 mCatmullRomSpline.insert(mCatmullRomSpline.begin(),a);
90 mCatmullRomSpline.push_back(b);
100 t =
clamp(t, 0.0f, 1.0f);
108 int i = 1 + (int)((size-1)*t);
114 float tt = (size-1)*t - int((size-1)*t);
119 T p = ( (p1 * 2.0f) + (-p0 + p2) * tt +
120 ( p0*2.0f - p1*5.0f + p2*4.0f - p3) * tt*tt +
121 ( p0*-1 + p1*3.0f - p2*3.0f + p3) * tt*tt*tt ) * 0.5f;
160 CatmullRomInterpolatorFVec4_T*
interpolator() {
return mInterpolator.get(); }
161 const CatmullRomInterpolatorFVec4_T*
interpolator()
const {
return mInterpolator.get(); }
162 void setInterpolator(CatmullRomInterpolatorFVec4_T* interpolator) { mInterpolator = interpolator; }
174 CatmullRomInterpolatorFVec3_T*
interpolator() {
return mInterpolator.get(); }
175 const CatmullRomInterpolatorFVec3_T*
interpolator()
const {
return mInterpolator.get(); }
176 void setInterpolator(CatmullRomInterpolatorFVec3_T* interpolator) { mInterpolator = interpolator; }
188 CatmullRomInterpolatorFVec2_T*
interpolator() {
return mInterpolator.get(); }
189 const CatmullRomInterpolatorFVec2_T*
interpolator()
const {
return mInterpolator.get(); }
190 void setInterpolator(CatmullRomInterpolatorFVec2_T* interpolator) { mInterpolator = interpolator; }
201 float computePoint(
float t)
const {
return interpolator()->computePoint(t); }
202 CatmullRomInterpolatorFloat_T*
interpolator() {
return mInterpolator.get(); }
203 const CatmullRomInterpolatorFloat_T*
interpolator()
const {
return mInterpolator.get(); }
204 void setInterpolator(CatmullRomInterpolatorFloat_T* interpolator) { mInterpolator = interpolator; }
216 CatmullRomInterpolatorDVec4_T*
interpolator() {
return mInterpolator.get(); }
217 const CatmullRomInterpolatorDVec4_T*
interpolator()
const {
return mInterpolator.get(); }
218 void setInterpolator(CatmullRomInterpolatorDVec4_T* interpolator) { mInterpolator = interpolator; }
230 CatmullRomInterpolatorDVec3_T*
interpolator() {
return mInterpolator.get(); }
231 const CatmullRomInterpolatorDVec3_T*
interpolator()
const {
return mInterpolator.get(); }
232 void setInterpolator(CatmullRomInterpolatorDVec3_T* interpolator) { mInterpolator = interpolator; }
244 CatmullRomInterpolatorDVec2_T*
interpolator() {
return mInterpolator.get(); }
245 const CatmullRomInterpolatorDVec2_T*
interpolator()
const {
return mInterpolator.get(); }
246 void setInterpolator(CatmullRomInterpolatorDVec2_T* interpolator) { mInterpolator = interpolator; }
257 double computePoint(
float t)
const {
return interpolator()->computePoint(t); }
258 CatmullRomInterpolatorDouble_T*
interpolator() {
return mInterpolator.get(); }
259 const CatmullRomInterpolatorDouble_T*
interpolator()
const {
return mInterpolator.get(); }
260 void setInterpolator(CatmullRomInterpolatorDouble_T* interpolator) { mInterpolator = interpolator; }
const CatmullRomInterpolatorFloat_T * interpolator() const
CatmullRomInterpolator< float > CatmullRomInterpolatorFloat_T
Abstract class that interpolates vl::fvec2 values.
ref< CatmullRomInterpolatorDVec4_T > mInterpolator
float clamp(float x, float minval, float maxval)
CatmullRomInterpolatorDVec3_T * interpolator()
CatmullRomInterpolatorDVec3(const std::vector< dvec3 > &path)
const CatmullRomInterpolatorFVec2_T * interpolator() const
CatmullRomInterpolatorDVec4_T * interpolator()
void setInterpolator(CatmullRomInterpolatorFloat_T *interpolator)
CatmullRomInterpolatorFVec3(const std::vector< fvec3 > &path)
dvec4 computePoint(float t) const
Samples the interpolator at the given point.
Abstract class that interpolates vl::dvec4 values.
void setInterpolator(CatmullRomInterpolatorFVec4_T *interpolator)
CatmullRomInterpolator< dvec4 > CatmullRomInterpolatorDVec4_T
CatmullRomInterpolatorFloat()
Abstract class that interpolates vl::dvec2 values.
CatmullRomInterpolatorDVec3()
Interpolates float values using a CatmullRomInterpolator.
void setInterpolator(CatmullRomInterpolatorDouble_T *interpolator)
T computePoint(float t) const
Samples the Catmull-Rom spline at the given point. The t parameter must be in the range 0...
CatmullRomInterpolatorDouble_T * interpolator()
void setInterpolator(CatmullRomInterpolatorFVec3_T *interpolator)
The LinearInterpolator class is a template class that implements Catmull-Rom spline interpolation...
Abstract class that interpolates double values.
Abstract class that interpolates float values.
CatmullRomInterpolatorFloat_T * interpolator()
CatmullRomInterpolatorFVec4_T * interpolator()
fvec4 computePoint(float t) const
Samples the interpolator at the given point.
CatmullRomInterpolator< fvec4 > CatmullRomInterpolatorFVec4_T
const CatmullRomInterpolatorDouble_T * interpolator() const
const CatmullRomInterpolatorDVec4_T * interpolator() const
ref< CatmullRomInterpolatorFVec4_T > mInterpolator
CatmullRomInterpolator< fvec3 > CatmullRomInterpolatorFVec3_T
void setPath(const std::vector< T > &path)
The control points defining the Catmull-Rom spline.
Interpolates double values using a CatmullRomInterpolator.
CatmullRomInterpolatorDouble()
Interpolates dvec2 values using a CatmullRomInterpolator.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
CatmullRomInterpolatorDVec2_T * interpolator()
ref< CatmullRomInterpolatorFVec2_T > mInterpolator
CatmullRomInterpolatorFVec2()
ref< CatmullRomInterpolatorFloat_T > mInterpolator
Visualization Library main namespace.
CatmullRomInterpolatorFVec2(const std::vector< fvec2 > &path)
CatmullRomInterpolator< double > CatmullRomInterpolatorDouble_T
ref< CatmullRomInterpolatorDVec3_T > mInterpolator
Interpolates fvec2 values using a CatmullRomInterpolator.
fvec3 computePoint(float t) const
Samples the interpolator at the given point.
double computePoint(float t) const
Samples the interpolator at the given point.
CatmullRomInterpolatorDVec2(const std::vector< dvec2 > &path)
fvec2 computePoint(float t) const
Samples the interpolator at the given point.
CatmullRomInterpolatorDVec4()
CatmullRomInterpolatorFVec4(const std::vector< fvec4 > &path)
Interpolates dvec4 values using a CatmullRomInterpolator.
ref< CatmullRomInterpolatorDouble_T > mInterpolator
CatmullRomInterpolator< dvec3 > CatmullRomInterpolatorDVec3_T
The base class for all the reference counted objects.
CatmullRomInterpolatorFVec3()
CatmullRomInterpolatorFVec4()
const CatmullRomInterpolatorDVec2_T * interpolator() const
ref< CatmullRomInterpolatorFVec3_T > mInterpolator
CatmullRomInterpolator< dvec2 > CatmullRomInterpolatorDVec2_T
float computePoint(float t) const
Samples the interpolator at the given point.
CatmullRomInterpolatorDVec4(const std::vector< dvec4 > &path)
Interpolates fvec4 values using a CatmullRomInterpolator.
void setInterpolator(CatmullRomInterpolatorDVec3_T *interpolator)
CatmullRomInterpolatorFloat(const std::vector< float > &path)
void setupEndPoints(bool is_loop)
Call this function after having specified the control points if you want to automatically generate th...
std::vector< T > mCatmullRomSpline
CatmullRomInterpolatorDVec2()
CatmullRomInterpolatorFVec2_T * interpolator()
Interpolates dvec3 values using a CatmullRomInterpolator.
void setInterpolator(CatmullRomInterpolatorFVec2_T *interpolator)
std::vector< T > & path()
The control points defining the Catmull-Rom spline.
dvec2 computePoint(float t) const
Samples the interpolator at the given point.
CatmullRomInterpolator(const std::vector< T > &path)
Abstract class that interpolates vl::fvec3 values.
const std::vector< T > & path() const
The control points defining the Catmull-Rom spline.
const CatmullRomInterpolatorDVec3_T * interpolator() const
Interpolates fvec3 values using a CatmullRomInterpolator.
dvec3 computePoint(float t) const
Samples the interpolator at the given point.
The ref<> class is used to reference-count an Object.
const CatmullRomInterpolatorFVec4_T * interpolator() const
CatmullRomInterpolatorDouble(const std::vector< double > &path)
Abstract class that interpolates vl::dvec3 values.
ref< CatmullRomInterpolatorDVec2_T > mInterpolator
const CatmullRomInterpolatorFVec3_T * interpolator() const
void setInterpolator(CatmullRomInterpolatorDVec2_T *interpolator)
CatmullRomInterpolator< fvec2 > CatmullRomInterpolatorFVec2_T
void setInterpolator(CatmullRomInterpolatorDVec4_T *interpolator)
CatmullRomInterpolatorFVec3_T * interpolator()
Abstract class that interpolates vl::fvec4 values.