diff options
Diffstat (limited to 'src/qcommon/q_math.c')
-rw-r--r-- | src/qcommon/q_math.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/qcommon/q_math.c b/src/qcommon/q_math.c index 7a480510..be06f226 100644 --- a/src/qcommon/q_math.c +++ b/src/qcommon/q_math.c @@ -1297,3 +1297,32 @@ int Q_isnan( float x ) return (int)( (unsigned int)fi.ui >> 31 ); } +//------------------------------------------------------------------------ + +#ifndef Q3_VM +/* +===================== +Q_acos + +the msvc acos doesn't always return a value between -PI and PI: + +int i; +i = 1065353246; +acos(*(float*) &i) == -1.#IND0 + +===================== +*/ +float Q_acos(float c) { + float angle; + + angle = acos(c); + + if (angle > M_PI) { + return (float)M_PI; + } + if (angle < -M_PI) { + return (float)M_PI; + } + return angle; +} +#endif |