Main Page | Namespace List | Class List | Directories | File List | Namespace Members | Class Members | File Members

imath.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 #ifndef _IMATH_H_
00017 #define _IMATH_H_
00018 
00019 // types, exported (class, enum, struct, union, typedef)
00020 
00021 // variables, exported (extern)
00022 
00023 // functions, inlined (inline)
00024 
00026 namespace math {
00027 
00033   template<class T>
00034   inline const T&
00035   min( const T& lhs, const T& rhs) {
00036 
00037     return (lhs < rhs) ? lhs : rhs;
00038   }
00039 
00045   template<class T>
00046   inline const T&
00047   max( const T& lhs, const T& rhs) {
00048 
00049     return (lhs > rhs) ? lhs : rhs;
00050   }
00051 
00055   template<class T, class S>
00056   inline T
00057   sum3( const S& vec) {
00058  
00059     return vec[0] + vec[1] + vec[2];
00060   }
00061 
00065   template<class T, class S>
00066   inline T
00067   sum4( const S& vec) {
00068  
00069     return vec[0] + vec[1] + vec[2] + vec[3];
00070   }
00071 
00075   template<class T>
00076   inline T
00077   mul3( const T& lhs, const T& rhs) {
00078 
00079     return T( lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2]);
00080   }
00081 
00085   template<class T>
00086   inline T
00087   mul4( const T& lhs, const T& rhs) {
00088 
00089     return T( lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2], lhs[3]*rhs[3]);
00090   }
00091 
00095   template<class T, class S>
00096   inline S
00097   dot3( const T& lhs, const T& rhs) {
00098 
00099     return sum3( mul3( lhs, rhs));
00100   }
00101 
00105   template<class T, class S>
00106   inline S
00107   dot4( const T& lhs, const T& rhs) {
00108 
00109     return sum4( mul4( lhs, rhs));
00110   }
00111 
00115   template<class T>
00116   inline double
00117   dp4( const T& lhs, const T& rhs) {
00118 
00119     return ((lhs.x * rhs.x) + (lhs.y * rhs.y) + (lhs.z * rhs.z) + (lhs.w * rhs.w));
00120   }
00121 
00129   template<class T>
00130   inline bool
00131   check_epsilon( const T& val, const T& epsilon) {
00132 
00133     return ((val < epsilon) && (val > -epsilon));
00134   }
00135 
00143   template<class T>
00144   inline bool
00145   check_std_epsilon( const T& val) {
00146 
00147     return ((val < std::numeric_limits<T>::epsilon()) 
00148              && (val > (-1.0 * std::numeric_limits<T>::epsilon() )));
00149   }
00150 
00156   template< class Matrix, class Transform >
00157   void
00158   transformQuadric( Matrix& quadric, const Transform& transform) {
00159 
00160     MMatrix adj = transform.adjoint();
00161     quadric = adj * ( quadric * adj.transpose());
00162   }
00163 }
00164   
00165 // functions, exported (extern)
00166 
00167 #endif // #ifndef _IMATH_H_
00168 

Generated on Sat Dec 31 18:07:49 2005 for ICaster by  doxygen 1.4.4