aimstil  5.0.5
TrilinearInterpolation.h
Go to the documentation of this file.
1 #ifndef TIL_LINEAR_INTERPOLATION_H
2 #define TIL_LINEAR_INTERPOLATION_H
3 // TODO: this file should be rename "Linear interpolation"
4 
5 // includes from TIL library
6 #include "til/til_common.h"
7 #include "til/labels.h"
8 
9 namespace til
10 {
11 
13  template < typename T >
15  : public Interpolator_label
16  {
17  public: // typedefs
18 
20 
21  public:
22 
24  // NB: There is a priori no reason for f to be the same type as x.
25  // However, forcing x and f to have the same type forces the
26  // (necessary anyway) casting to be done once, before function
27  // call.
28  inline static T compute
29  (
30  T f1,
31  T f2,
32  T x
33  )
34  {
35  //return f2*x+f1*(1-x);
36  // this saves one multiplication!
37  return f1 + x*(f2-f1);
38  }
39  };
40 
41 } // namespace til
42 
43 
44 #endif
45 
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
Linear interpolation between two values.
General macros, definitions and functions.
Defines empty classes that serves as labels.
static T compute(T f1, T f2, T x)
Returns the linear interpolated value of two numbers.