Open Source Tomb Raider Engine
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*!
  2. *
  3. * \file include/MatMath.h
  4. * \brief Vector and Matrix math
  5. *
  6. * \author Mongoose
  7. */
  8. #ifndef _MATMATH_H
  9. #define _MATMATH_H
  10. #define HEL_PI 3.14159265358979323846 //!< pi
  11. #define HEL_PI_OVER_2 1.57079632679489661923 //!< pi/2
  12. #define HEL_2_PI 6.28318530717958647692 //!< pi*2
  13. #define HEL_PI_OVER_4 0.78539816339744830962 //!< pi/4
  14. #define HEL_PI_OVER_180 0.017453292519943295 //!< pi/180
  15. #define HEL_180_OVER_PI 57.295779513082323 //!< 180/pi
  16. #define HEL_RAD_TO_DEG(x) ((x) * HEL_180_OVER_PI) //!< Convert radians to degrees
  17. #define HEL_DEG_TO_RAD(x) ((x) * HEL_PI_OVER_180) //!< Convert degrees to radians
  18. typedef float vec_t; //!< 1D Vector, aka float
  19. typedef float vec2_t[2]; //!< 2D Vector
  20. typedef float vec3_t[3]; //!< 3D Vector
  21. typedef float vec4_t[4]; //!< 4D Vector
  22. typedef vec_t matrix_t[16]; //!< Used as _Column_major_ in every class now!
  23. /*!
  24. * \brief Calculate Intersection of a line and a polygon
  25. * \param intersect Where the intersection is stored, if it exists
  26. * \param p1 First point of line segment
  27. * \param p2 Second point of line segment
  28. * \param vertexCount number of vertices in polygon
  29. * \param polygon polygon vertex array
  30. * \returns 0 if there is no intersection
  31. */
  32. int helIntersectionLineAndPolygon(vec3_t intersect, vec3_t p1, vec3_t p2, unsigned int vertexCount, vec3_t *polygon);
  33. /*!
  34. * \brief Calculate the distance from a sphere to a plane
  35. * \param center Center of sphere
  36. * \param radius Radius of sphere
  37. * \param plane Plane
  38. * \returns distance
  39. */
  40. vec_t helDistToSphereFromPlane3v(vec3_t center, vec_t radius, vec4_t plane);
  41. /*!
  42. * \brief Calculate the distance from a box to a plane
  43. * \param min Minimum Point of a bounding box
  44. * \param max Maximum Point of a bounding box
  45. * \param plane Plane
  46. * \returns distance
  47. */
  48. vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane);
  49. /*!
  50. * \brief Calculate the length of a line segment / the distance between two points
  51. * \param a First point
  52. * \param b Second point
  53. * \returns distance/length
  54. */
  55. vec_t helDist3v(vec3_t a, vec3_t b);
  56. /*!
  57. * \brief Calculates the midpoint between two points / of a line segment
  58. * \param a First point
  59. * \param b Second point
  60. * \param mid Midpoint will be stored here
  61. */
  62. void helMidpoint3v(vec3_t a, vec3_t b, vec3_t mid);
  63. /*!
  64. * \brief Calculates a pseudo-random number
  65. * \param from Lower bound of resulting number
  66. * \param to Upper bound
  67. * \returns random number
  68. */
  69. vec_t helRandomNum(vec_t from, vec_t to);
  70. #endif