Math.h 1.3 KB

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