From Art Tevs, Added log2 function.

This commit is contained in:
Robert Osfield 2007-09-11 17:08:06 +00:00
parent 0bd4d303e3
commit b63ce0dee9

View File

@ -114,6 +114,9 @@ namespace osg {
const double PI = 3.14159265358979323846;
const double PI_2 = 1.57079632679489661923;
const double PI_4 = 0.78539816339744830962;
const double LN_2 = 0.69314718055994530942;
const double INVLN_2 = 1.0 / LN_2;
/** return the minimum of two values, equivalent to std::min.
* std::min not used because of STL implementation under IRIX not
@ -191,6 +194,10 @@ inline double RadiansToDegrees(double angle) { return angle*180.0/PI; }
inline float round(float v) { return v>=0.0f?floorf(v+0.5f):ceilf(v-0.5f); }
inline double round(double v) { return v>=0.0?floor(v+0.5):ceil(v-0.5); }
inline float log2(float v) { return static_cast<float>(log(v)) * INVLN_2; }
inline double log2(double v) { return static_cast<double>(log(v)) * INVLN_2; }
inline int log2(int v) { return static_cast<int>(floorf(log(v) * INVLN_2)); }
#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MWERKS__)
inline bool isNaN(float v) { return _isnan(v)!=0; }
inline bool isNaN(double v) { return _isnan(v)!=0; }