32 #ifndef __VMML__MATH__HPP__
33 #define __VMML__MATH__HPP__
38 # define M_PI 3.14159265358979323846
50 inline T squared(
const T a )
52 return ( a == 0.0 ) ? 0.0 : a * a;
61 inline T pythag( T a, T b )
66 return a * std::sqrt( 1.0 + squared( b / a ) );
68 return ( b == 0.0 ) ? 0.0 : b * sqrt( 1.0 + squared( a / b ) );
74 inline T sign( T a, T b )
76 return ( b >= 0.0 ) ? std::abs( a ) : -
std::abs( a );
81 template<
typename T >
84 T operator()(
const T& a,
const T& b )
86 return std::abs(a) < std::abs( b );
91 template<
typename T >
94 T operator()(
const T& a,
const T& b )
96 return std::abs(a) > std::abs( b );
heavily inspired by boost::enable_if http://www.boost.org, file: boost/utility/enable_if.hpp, Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine