C Math Abstraction | |
template<typename T> T | abs (T iValue) |
template<typename T> T | ceil (T fValue) |
float | ceil (float fValue) |
double | ceil (double fValue) |
template<typename T> T | floor (T fValue) |
float | floor (float fValue) |
double | floor (double fValue) |
template<typename T> int | sign (T iValue) |
template<typename T> T | zeroClamp (T value, T eps=T(0)) |
Clamps the given value down to zero if it is within epsilon of zero. More... | |
template<typename T> T | aCos (T fValue) |
float | aCos (float fValue) |
double | aCos (double fValue) |
template<typename T> T | aSin (T fValue) |
float | aSin (float fValue) |
double | aSin (double fValue) |
template<typename T> T | aTan (T fValue) |
double | aTan (double fValue) |
float | aTan (float fValue) |
template<typename T> T | atan2 (T fY, T fX) |
float | aTan2 (float fY, float fX) |
double | aTan2 (double fY, double fX) |
template<typename T> T | cos (T fValue) |
float | cos (float fValue) |
double | cos (double fValue) |
template<typename T> T | exp (T fValue) |
float | exp (float fValue) |
double | exp (double fValue) |
template<typename T> T | log (T fValue) |
double | log (double fValue) |
float | log (float fValue) |
double | pow (double fBase, double fExponent) |
float | pow (float fBase, float fExponent) |
template<typename T> T | sin (T fValue) |
double | sin (double fValue) |
float | sin (float fValue) |
template<typename T> T | tan (T fValue) |
double | tan (double fValue) |
float | tan (float fValue) |
template<typename T> T | sqr (T fValue) |
template<typename T> T | sqrt (T fValue) |
double | sqrt (double fValue) |
void | seedRandom (unsigned int seed) |
Seeds the pseudorandom number generator with the given seed. More... | |
float | unitRandom () |
get a random number between 0 and 1. More... | |
float | rangeRandom (float x1, float x2) |
return a random number between x1 and x2 RETURNS: random number between x1 and x2. More... | |
float | deg2Rad (float fVal) |
double | deg2Rad (double fVal) |
float | rad2Deg (float fVal) |
double | rad2Deg (double fVal) |
template<class T> bool | isEqual (const T &a, const T &b, const T &tolerance) |
Is almost equal? test for equality within some tolerance... More... | |
template<class T> T | trunc (T val) |
cut off the digits after the decimal place. More... | |
template<class T> T | round (T p) |
round to nearest integer. More... | |
template<class T> T | Min (const T &x, const T &y) |
min returns the minimum of 2 values. More... | |
template<class T> T | Min (const T &x, const T &y, const T &z) |
min returns the minimum of 3 values. More... | |
template<class T> T | Min (const T &w, const T &x, const T &y, const T &z) |
min returns the minimum of 4 values. More... | |
template<class T> T | Max (const T &x, const T &y) |
max returns the maximum of 2 values. More... | |
template<class T> T | Max (const T &x, const T &y, const T &z) |
max returns the maximum of 3 values. More... | |
template<class T> T | Max (const T &w, const T &x, const T &y, const T &z) |
max returns the maximum of 4 values. More... | |
template<class T> T | factorial (T rhs) |
Compute the factorial. More... | |
Mathematical constants | |
const float | PI = 3.14159265358979323846f |
const float | PI_OVER_2 = 1.57079632679489661923f |
const float | PI_OVER_4 = 0.78539816339744830962f |
|
Definition at line 81 of file Math.h. Referenced by gmtl::Eigen::QLAlgorithm, and gmtl::Eigen::TridiagonalN.
00082 { 00083 return T( iValue >= ((T)0) ? iValue : -iValue ); 00084 } |
|
Definition at line 176 of file Math.h.
00177 { 00178 if ( -1.0 < fValue ) 00179 { 00180 if ( fValue < 1.0 ) 00181 return double( ::acos( fValue ) ); 00182 else 00183 return 0.0; 00184 } 00185 else 00186 { 00187 return (double)gmtl::Math::PI; 00188 } 00189 } |
|
Definition at line 156 of file Math.h.
00157 { 00158 if ( -1.0f < fValue ) 00159 { 00160 if ( fValue < 1.0f ) 00161 { 00162 #ifdef NO_ACOSF 00163 return float(::acos(fValue)); 00164 #else 00165 return float( ::acosf( fValue ) ); 00166 #endif 00167 } 00168 else 00169 return 0.0f; 00170 } 00171 else 00172 { 00173 return (float)gmtl::Math::PI; 00174 } 00175 } |
|
|
|
Definition at line 213 of file Math.h.
00214 { 00215 if ( -1.0 < fValue ) 00216 { 00217 if ( fValue < 1.0 ) 00218 return double( ::asin( fValue ) ); 00219 else 00220 return (double)-gmtl::Math::PI_OVER_2; 00221 } 00222 else 00223 { 00224 return (double)gmtl::Math::PI_OVER_2; 00225 } 00226 } |
|
Definition at line 193 of file Math.h.
00194 { 00195 if ( -1.0f < fValue ) 00196 { 00197 if ( fValue < 1.0f ) 00198 { 00199 #ifdef NO_ASINF 00200 return float(::asin(fValue)); 00201 #else 00202 return float( ::asinf( fValue ) ); 00203 #endif 00204 } 00205 else 00206 return (float)-gmtl::Math::PI_OVER_2; 00207 } 00208 else 00209 { 00210 return (float)gmtl::Math::PI_OVER_2; 00211 } 00212 } |
|
|
|
Definition at line 234 of file Math.h.
00235 { 00236 #ifdef NO_TANF 00237 return float(::atan(fValue)); 00238 #else 00239 return float( ::atanf( fValue ) ); 00240 #endif 00241 } |
|
Definition at line 230 of file Math.h.
00231 { 00232 return ::atan( fValue ); 00233 } |
|
|
|
Definition at line 253 of file Math.h.
00254 { 00255 return double( ::atan2( fY, fX ) ); 00256 } |
|
Definition at line 245 of file Math.h.
00246 { 00247 #ifdef NO_ATAN2F 00248 return float(::atan2(fY, fX)); 00249 #else 00250 return float( ::atan2f( fY, fX ) ); 00251 #endif 00252 } |
|
|
|
Definition at line 96 of file Math.h.
00097 { 00098 return double( ::ceil( fValue ) ); 00099 } |
|
Definition at line 88 of file Math.h.
00089 { 00090 #ifdef NO_CEILF 00091 return float(::ceil(fValue)); 00092 #else 00093 return float( ::ceilf( fValue ) ); 00094 #endif 00095 } |
|
|
|
Definition at line 268 of file Math.h.
00269 { 00270 return double( ::cos( fValue ) ); 00271 } |
|
Definition at line 260 of file Math.h.
00261 { 00262 #ifdef NO_COSF 00263 return float(::cos(fValue)); 00264 #else 00265 return float( ::cosf( fValue ) ); 00266 #endif 00267 } |
|
|
|
Definition at line 407 of file Math.h.
00408 { 00409 return double( fVal * (double)(gmtl::Math::PI/180.0) ); 00410 } |
|
Definition at line 403 of file Math.h.
00404 { 00405 return float( fVal * (float)(gmtl::Math::PI/180.0) ); 00406 } |
|
Definition at line 283 of file Math.h.
00284 { 00285 return double( ::exp( fValue ) ); 00286 } |
|
Definition at line 275 of file Math.h.
00276 { 00277 #ifdef NO_EXPF 00278 return float(::exp(fValue)); 00279 #else 00280 return float( ::expf( fValue ) ); 00281 #endif 00282 } |
|
|
|
Compute the factorial. give - an object who's type has operator++, operator=, operator<=, and operator *= defined. it should be a single valued scalar type such as an int, float, double etc.... NOTE: This could be faster with a lookup table, but then wouldn't work templated : kevin Definition at line 490 of file Math.h.
00491 { 00492 T lhs = (T)1; 00493 00494 for( T x = (T)1; x <= rhs; ++x ) 00495 { 00496 lhs *= x; 00497 } 00498 00499 return lhs; 00500 } |
|
Definition at line 111 of file Math.h.
00112 { 00113 return double( ::floor( fValue ) ); 00114 } |
|
Definition at line 103 of file Math.h.
00104 { 00105 #ifdef NO_FLOORF 00106 return float(::floor(fValue)); 00107 #else 00108 return float( ::floorf( fValue ) ); 00109 #endif 00110 } |
|
|
|
Is almost equal? test for equality within some tolerance... @PRE: tolerance must be >= 0 Definition at line 427 of file Math.h.
00428 { 00429 gmtlASSERT( tolerance >= (T)0 ); 00430 return bool( gmtl::Math::abs( a - b ) <= tolerance ); 00431 } |
|
Definition at line 294 of file Math.h.
00295 { 00296 #ifdef NO_LOGF 00297 return float(::log(fValue)); 00298 #else 00299 return float( ::logf( fValue ) ); 00300 #endif 00301 } |
|
Definition at line 290 of file Math.h.
00291 { 00292 return double( ::log( fValue ) ); 00293 } |
|
|
|
max returns the maximum of 4 values.
Definition at line 479 of file Math.h.
00480 { 00481 return gmtl::Math::Max( gmtl::Math::Max( w, x ), gmtl::Math::Max( y, z ) ); 00482 } |
|
max returns the maximum of 3 values.
Definition at line 473 of file Math.h.
00474 { 00475 return Max( gmtl::Math::Max( x, y ), z ); 00476 } |
|
max returns the maximum of 2 values.
Definition at line 467 of file Math.h.
00468 { 00469 return ( x > y ) ? x : y; 00470 } |
|
min returns the minimum of 4 values.
Definition at line 460 of file Math.h. Referenced by gmtl::Matrix::Matrix.
00461 { 00462 return gmtl::Math::Min( gmtl::Math::Min( w, x ), gmtl::Math::Min( y, z ) ); 00463 } |
|
min returns the minimum of 3 values.
Definition at line 454 of file Math.h.
00455 { 00456 return Min( gmtl::Math::Min( x, y ), z ); 00457 } |
|
min returns the minimum of 2 values.
Definition at line 448 of file Math.h.
00449 { 00450 return ( x > y ) ? y : x; 00451 } |
|
Definition at line 307 of file Math.h.
00308 { 00309 #ifdef NO_POWF 00310 return float(::pow(fBase, fExponent)); 00311 #else 00312 return float( ::powf( fBase, fExponent ) ); 00313 #endif 00314 } |
|
Definition at line 303 of file Math.h.
00304 { 00305 return double( ::pow( fBase, fExponent ) ); 00306 } |
|
Definition at line 416 of file Math.h.
00417 { 00418 return double( fVal * (double)(180.0/gmtl::Math::PI) ); 00419 } |
|
Definition at line 412 of file Math.h.
00413 { 00414 return float( fVal * (float)(180.0/gmtl::Math::PI) ); 00415 } |
|
return a random number between x1 and x2 RETURNS: random number between x1 and x2.
Definition at line 388 of file Math.h.
00389 { 00390 float r = gmtl::Math::unitRandom(); 00391 float size = x2 - x1; 00392 return float( r * size + x1 ); 00393 } |
|
round to nearest integer.
Definition at line 441 of file Math.h.
00442 { 00443 return T( gmtl::Math::floor( p + (T)0.5 ) ); 00444 } |
|
Seeds the pseudorandom number generator with the given seed.
Definition at line 372 of file Math.h.
00373 { 00374 ::srand(seed); 00375 } |
|
Definition at line 117 of file Math.h.
00118 { 00119 if (iValue > T(0)) 00120 { 00121 return 1; 00122 } 00123 else 00124 { 00125 if (iValue < T(0)) 00126 { 00127 return -1; 00128 } 00129 else 00130 { 00131 return 0; 00132 } 00133 } 00134 } |
|
Definition at line 322 of file Math.h.
00323 { 00324 #ifdef NO_SINF 00325 return float(::sin(fValue)); 00326 #else 00327 return float( ::sinf( fValue ) ); 00328 #endif 00329 } |
|
Definition at line 318 of file Math.h.
00319 { 00320 return double( ::sin( fValue ) ); 00321 } |
|
|
|
Definition at line 347 of file Math.h.
00348 { 00349 return T( fValue * fValue ); 00350 } |
|
Definition at line 361 of file Math.h. Referenced by gmtl::Eigen::QLAlgorithm, gmtl::Eigen::Tridiagonal3, gmtl::Eigen::Tridiagonal4, and gmtl::Eigen::TridiagonalN.
00362 { 00363 return double( ::sqrt( fValue ) ); 00364 } |
|
Definition at line 353 of file Math.h.
00354 { 00355 #ifdef NO_SQRTF 00356 return T(::sqrt(((float)fValue))); 00357 #else 00358 return T( ::sqrtf( ((float)fValue) ) ); 00359 #endif 00360 } |
|
Definition at line 337 of file Math.h.
00338 { 00339 #ifdef NO_TANF 00340 return float(::tan(fValue)); 00341 #else 00342 return float( ::tanf( fValue ) ); 00343 #endif 00344 } |
|
Definition at line 333 of file Math.h.
00334 { 00335 return double( ::tan( fValue ) ); 00336 } |
|
|
|
cut off the digits after the decimal place.
Definition at line 435 of file Math.h.
00436 { 00437 return T( (val < ((T)0)) ? gmtl::Math::ceil( val ) : gmtl::Math::floor( val ) ); 00438 } |
|
get a random number between 0 and 1.
Definition at line 380 of file Math.h.
00381 { 00382 return float(::rand())/float(RAND_MAX); 00383 } |
|
Clamps the given value down to zero if it is within epsilon of zero.
Definition at line 145 of file Math.h.
00146 { 00147 return ( (gmtl::Math::abs(value) <= eps) ? T(0) : value ); 00148 } |
|
|
|
|
|
|