Blender  V2.59
tnt_math_utils.h
Go to the documentation of this file.
00001 
00004 #ifndef MATH_UTILS_H
00005 #define MATH_UTILS_H
00006 
00007 /* needed for fabs, sqrt() below */
00008 #include <cmath>
00009 
00010 #ifdef _WIN32
00011 #define hypot _hypot
00012 #endif
00013 
00014 namespace TNT
00015 {
00022 template <class Real>
00023 Real hypot(const Real &a, const Real &b)
00024 {
00025         
00026         if (a== 0)
00027                 return fabs(b);
00028         else
00029         {
00030                 Real c = b/a;
00031                 return fabs(a) * sqrt(1 + c*c);
00032         }
00033 }
00034 } /* TNT namespace */
00035 
00036 
00037 
00038 #endif
00039 /* MATH_UTILS_H */