angle.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Copyright (C) 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. * angle.h: Angle 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 __ANGLE_H__
  27. #define __ANGLE_H__
  28. #define DEG2RAD( a ) ( (a) * 0.01745329251994329576f ) // a * M_PI / 180.0f
  29. #define RAD2DEG( a ) ( (int)((a) / 0.01745329251994329576f) ) // a * 180.0f / M_PI
  30. #define ANGLE2SHORT( x ) ( (int)((x) * 65536 / 360) & 65535 )
  31. #define SHORT2ANGLE( x ) ( (x) * (360.0 / 65536) )
  32. extern float angle_diff( float angle1, float angle2 );
  33. extern float angle_wise( float angle1, float angle2 );
  34. extern float interpolate_angle( float from, float to, float fraction );
  35. extern float normalize_angle( float angle );
  36. extern float LerpAngle( float from, float to, float frac );
  37. #endif /* __ANGLE_H__ */