Math.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef MATH_H
  2. #define MATH_H
  3. #include "MathCommonIncludes.h"
  4. /// @addtogroup Math
  5. /// @{
  6. /// Useful and optimized math functions
  7. class Math
  8. {
  9. public:
  10. static const float PI;
  11. static const float EPSILON;
  12. /// A fast func that given the angle in rads it returns the sin and cos
  13. static void sinCos(const float rad, float& sin_, float& cos_);
  14. /// Optimized square root
  15. static float sqrt(const float f);
  16. /// Convert
  17. static float toRad(const float degrees);
  18. /// Convert
  19. static float toDegrees(const float rad);
  20. /// Optimized sine
  21. static float sin(const float rad);
  22. /// Optimized cosine
  23. static float cos(const float rad);
  24. /// The proper way to test if a float is zero
  25. static bool isZero(const float f);
  26. /// Mat4(t0,r0,s0) * Mat4(t1, r1, s1) == Mat4(tf, rf, sf)
  27. static void combineTransformations(
  28. const Vec3& t0, const Mat3& r0, const float s0, // in 0
  29. const Vec3& t1, const Mat3& r1, const float s1, // in 1
  30. Vec3& tf, Mat3& rf, float& sf); // out
  31. /// Mat4(t0, r0, 1.0) * Mat4(t1, r1, 1.0) == Mat4(tf, rf, sf)
  32. static void combineTransformations(
  33. const Vec3& t0, const Mat3& r0, // in 0
  34. const Vec3& t1, const Mat3& r1, // in 1
  35. Vec3& tf, Mat3& rf); // out
  36. private:
  37. static float polynomialSinQuadrant(const float a);
  38. };
  39. /// @}
  40. #include "Math.inl.h"
  41. #endif