mymath.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. Copyright (C) 2004-2005 Michael Liebscher <johnnycanuck@users.sourceforge.net>
  3. Copyright (C) 1997-2001 Id Software, Inc.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. /*
  17. * mymath.h: Math routines.
  18. *
  19. * Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
  20. *
  21. * Acknowledgement:
  22. * Portion of this code was derived from Quake II, and was originally
  23. * written by Id Software, Inc.
  24. *
  25. */
  26. #ifndef __MYMATH_H__
  27. #define __MYMATH_H__
  28. typedef int fixed4_t;
  29. typedef int fixed8_t;
  30. typedef int fixed16_t;
  31. #define PITCH 0 /* up / down */
  32. #define YAW 1 /* left / right */
  33. #define ROLL 2 /* fall over */
  34. #ifndef M_PI
  35. #define M_PI 3.14159265358979323846f // matches value in gcc v2 math.h
  36. #endif
  37. #ifndef ABS
  38. #define ABS( x ) ( (x) < 0 ? -(x) : (x) )
  39. #endif
  40. #define nanmask ( 255 << 23 )
  41. #define IS_NAN( x ) ( ( (*(int *) &x ) & nanmask ) == nanmask )
  42. /* Use RINT() instead of rint() */
  43. #ifdef __GNUC__
  44. #define RINT( x ) rint( x )
  45. #else
  46. #define RINT( x ) floor( (x) + 0.5 )
  47. #endif
  48. extern void MathLib_Init( void );
  49. extern int my_log2( int val );
  50. extern float (*pfSqrt)( float x );
  51. extern float CalcFov( float fov_x, float width, float height );
  52. #endif /* __MYMATH_H__ */