CCatmullRomSplineInterpolator.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ISplineInterpolator.h"
5 
6 
7 namespace ion
8 {
9  namespace Animation
10  {
11 
12  template <typename T>
14  {
15 
16  public:
17 
18  virtual T Interpolate(ISpline<T> const & Path, int const Index, float const Mu);
19 
20  };
21 
22  template <typename T>
23  T CCatmullRomSplineInterpolator<T>::Interpolate(ISpline<T> const & Path, int const Index, float const Mu)
24  {
25  T const P0 = Path.GetNode(Index - 1);
26  T const P1 = Path.GetNode(Index + 0);
27  T const P2 = Path.GetNode(Index + 1);
28  T const P3 = Path.GetNode(Index + 2);
29 
30  float const t = Mu;
31  float const t2 = Sq(t);
32  float const t3 = t2*t;
33 
34  return ((P1 * 2.0) + (P0*-1.0 + P2) * t + (P0*2.0 - P1*5.0 + P2*4.0 - P3) * t2 + (P0*-1.0 + P1*3.0 - P2*3.0 + P3) * t3) * 0.5;
35  }
36 
37  }
38 }
T Sq(T const &a)
Definition: ionUtils.h:60
Definition: ISplineInterpolator.h:14
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
Definition: CCatmullRomSplineInterpolator.h:13
virtual T Interpolate(ISpline< T > const &Path, int const Index, float const Mu)
Definition: CCatmullRomSplineInterpolator.h:23
Definition: ISpline.h:13
virtual TSplineNode const & GetNode(int const Index) const =0