Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

math.h 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*!
  2. *
  3. * \file include/math/math.h
  4. * \brief Vector and Matrix math
  5. *
  6. * \author Mongoose
  7. * \author xythobuz
  8. */
  9. #ifndef _MATH_MATH_H
  10. #define _MATH_MATH_H
  11. #ifndef M_PI
  12. #define OR_PI (3.14159265358979323846f) //!< pi
  13. #else
  14. #define OR_PI ((float)M_PI) //!< pi
  15. #endif
  16. #define OR_RAD_TO_DEG(x) ((x) * (180.0f / OR_PI)) //!< Convert radians to degrees
  17. #define OR_DEG_TO_RAD(x) ((x) * (OR_PI / 180.0f)) //!< Convert degrees to radians
  18. /*!
  19. * \brief Compare two floats with an Epsilon.
  20. * \param a first float
  21. * \param b second float
  22. * \returns true if a and b are probably the same.
  23. */
  24. bool equalEpsilon(float a, float b);
  25. /*!
  26. * \brief Calculate Intersection of a line and a polygon
  27. * \param intersect Where the intersection is stored, if it exists
  28. * \param p1 First point of line segment
  29. * \param p2 Second point of line segment
  30. * \param polygon polygon vertex array (0 to 2 are used)
  31. * \returns 0 if there is no intersection
  32. */
  33. int intersectionLinePolygon(float intersect[3], float p1[3], float p2[3], float polygon[3][3]);
  34. /*!
  35. * \brief Calculate the length of a line segment / the distance between two points
  36. * \param a First point
  37. * \param b Second point
  38. * \returns distance/length
  39. */
  40. float distance(const float a[3], const float b[3]);
  41. /*!
  42. * \brief Calculates the midpoint between two points / of a line segment
  43. * \param a First point
  44. * \param b Second point
  45. * \param mid Midpoint will be stored here
  46. */
  47. void midpoint(const float a[3], const float b[3], float mid[3]);
  48. /*!
  49. * \brief Calculates a pseudo-random number
  50. * \param from Lower bound of resulting number
  51. * \param to Upper bound
  52. * \returns random number
  53. */
  54. float randomNum(float from, float to);
  55. #endif