Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __parallelsurf_math_h
00025 #define __parallelsurf_math_h
00026
00027 #include <vector>
00028
00029 #define PI 3.14159
00030
00031 namespace parallelsurf
00032 {
00033
00034 struct Math
00035 {
00036 static bool SolveLinearSystem33 ( double *solution, double sq[3][3] );
00037 static inline double Abs ( const double iD ) { return ( iD > 0.0 ? iD : -iD ); }
00038 static inline int Round ( const double iD ) { return ( int ) ( iD + 0.5 ); }
00039 static bool Normalize ( std::vector<double> &iVec );
00040 };
00041
00042 template < int LBound = -128, int UBound = 127, class TResult = double, class TArg = double >
00043 class LUT
00044 {
00045 public:
00046 explicit LUT ( TResult ( *f ) ( TArg ), double coeffadd = 0, double coeffmul = 1 )
00047 {
00048 lut = lut_array - LBound;
00049 for ( int i = LBound; i <= UBound; i++ )
00050 {
00051 lut[i] = f ( coeffmul * ( i + coeffadd ) );
00052 }
00053 }
00054
00055 const TResult & operator() ( int i ) const
00056 {
00057 return lut[i];
00058 }
00059 private:
00060 TResult lut_array[UBound - LBound + 1];
00061 TResult * lut;
00062 };
00063
00064 }
00065
00066 #endif //__parallelsurf_math_h