aimstil  5.0.5
catmull_rom_interpolation.tpp
Go to the documentation of this file.
1 #ifndef TIL_CATMULL_ROM_INTERPOLATION_TPP_
2 #define TIL_CATMULL_ROM_INTERPOLATION_TPP_
3 
4 namespace til
5 {
6  namespace
7  {
8  template < typename T >
9  static inline T CRPo(T x)
10  { return x*x*(x-1)/T(2.0); }
11 
12  template < typename T >
13  static inline T lapl_(T x1, T x2, T x3)
14  { return x1 + x3 - 2*x2; }
15  }
16 
17 
18  template < typename T >
19  T CatmullRomInterpolation<T>::compute(T f1, T f2, T f3, T f4, T x)
20  {
21  return
22  CRPo(x) * lapl_(f2, f3, f4) + x * f3 +
23  CRPo(1-x) * lapl_(f1, f2, f3) + (1-x) * f2;
24  }
25 
26 } // namespace til
27 
28 #endif /*CATMULL_ROM_INTERPOLATION_TPP_*/