mathlib.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /***
  2. *
  3. * Copyright (c) 1998, Valve LLC. All rights reserved.
  4. *
  5. * This product contains software technology licensed from Id
  6. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
  7. * All Rights Reserved.
  8. *
  9. ****/
  10. #ifndef __MATHLIB__
  11. #define __MATHLIB__
  12. #include <math.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #ifdef DOUBLEVEC_T
  17. typedef double vec_t;
  18. #else
  19. typedef float vec_t;
  20. #endif
  21. typedef vec_t vec3_t[3]; // x,y,z
  22. typedef vec_t vec4_t[4]; // x,y,z,w
  23. #define Q_PI 3.14159265358979323846
  24. #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
  25. void ClearBounds (vec3_t mins, vec3_t maxs);
  26. void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);
  27. void AngleMatrix (const vec3_t angles, float matrix[3][4] );
  28. void R_ConcatTransforms (const float in1[3][4], const float in2[3][4], float out[3][4]);
  29. void VectorIRotate (const vec3_t in1, const float in2[3][4], vec3_t out);
  30. void VectorRotate (const vec3_t in1, const float in2[3][4], vec3_t out);
  31. void VectorTransform (const vec3_t in1, const float in2[3][4], vec3_t out);
  32. void VectorITransform (const vec3_t in1, const float in2[3][4], vec3_t out);
  33. void AngleQuaternion( const vec3_t angles, vec4_t quaternion );
  34. void QuaternionMatrix( const vec4_t quaternion, float (*matrix)[4] );
  35. void QuaternionSlerp( const vec4_t p, vec4_t q, float t, vec4_t qt );
  36. #ifdef __cplusplus
  37. }
  38. #endif
  39. #endif