15 #ifndef INCLUDED_numeric_interpolation_interpolation_hh
16 #define INCLUDED_numeric_interpolation_interpolation_hh
29 namespace interpolation {
34 template<
typename X,
typename F >
45 assert( x2 - x1 !=
X( 0 ) );
46 return f1 + ( ( x - x1 ) / ( x2 - x1 ) ) * ( f2 - f1 );
52 template<
typename X,
typename F >
61 return f1 + ( a * ( f2 - f1 ) );
67 template<
typename X,
typename F >
76 return a * ( f2 - f1 );
81 template<
typename X,
typename Y,
typename F >
97 assert( x2 - x1 !=
X( 0 ) );
98 assert( y2 - y1 != Y( 0 ) );
99 X const ax( ( x - x2 ) / ( x2 - x1 ) );
100 Y
const ay( ( y - y2 ) / ( y2 - y1 ) );
101 X const bx(
X( 1.0 ) - ax );
102 Y
const by( Y( 1.0 ) - ay );
112 template<
typename X,
typename Y,
typename F >
124 X const bx(
X( 1.0 ) - ax );
125 Y
const by( Y( 1.0 ) - ay );
135 template<
typename X,
typename Y,
typename F >
163 #endif // INCLUDED_numeric_interpolation_interpolation_HH
F interpolated_delta(X const &a, F const &f1, F const &f2)
Linearly interpolated delta value: f( x ) - f1.
bool eq_tol(T const &x, T const &y, T const &r_tol, T const &a_tol)
Equal within specified relative and absolute tolerances?
NumericTraits: Numeric type traits.
F interpolated(X const &x, X const &x1, X const &x2, F const &f1, F const &f2)
Linearly interpolated value: f( x )
F bilinearly_interpolated(X const &x, X const &x1, X const &x2, Y const &y, Y const &y1, Y const &y2, F const &f11, F const &f12, F const &f21, F const &f22)
Bilinearly interpolated value: f( x, y )