Transform.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef ANKI_MATH_TRANSFORM_H
  2. #define ANKI_MATH_TRANSFORM_H
  3. #include "anki/math/Vec3.h"
  4. #include "anki/math/Mat3.h"
  5. #include "anki/math/CommonIncludes.h"
  6. namespace anki {
  7. /// @addtogroup Math
  8. /// @{
  9. /// Transformation
  10. class Transform
  11. {
  12. public:
  13. /// @name Constructors
  14. /// @{
  15. explicit Transform();
  16. Transform(const Transform& b);
  17. explicit Transform(const Mat4& m4);
  18. explicit Transform(const Vec3& origin, const Mat3& rotation,
  19. const F32 scale);
  20. /// @}
  21. /// @name Accessors
  22. /// @{
  23. const Vec3& getOrigin() const;
  24. Vec3& getOrigin();
  25. void setOrigin(const Vec3 o);
  26. const Mat3& getRotation() const;
  27. Mat3& getRotation();
  28. void setRotation(const Mat3& r);
  29. F32 getScale() const;
  30. F32& getScale();
  31. void setScale(const F32 s);
  32. /// @}
  33. /// @name Operators with same type
  34. /// @{
  35. Transform& operator=(const Transform& b);
  36. Bool operator==(const Transform& b) const;
  37. Bool operator!=(const Transform& b) const;
  38. /// @}
  39. /// @name Other
  40. /// @{
  41. void setIdentity();
  42. static const Transform& getIdentity();
  43. static void combineTransformations(
  44. const Vec3& t0, const Mat3& r0, const F32 s0,
  45. const Vec3& t1, const Mat3& r1, const F32 s1,
  46. Vec3& tf, Mat3& rf, F32& sf);
  47. static void combineTransformations(
  48. const Vec3& t0, const Mat3& r0,
  49. const Vec3& t1, const Mat3& r1,
  50. Vec3& tf, Mat3& rf);
  51. static Transform combineTransformations(const Transform& a,
  52. const Transform& b); ///< @copybrief combineTransformations
  53. /// Get the inverse transformation. Its faster that inverting a Mat4
  54. Transform getInverse() const;
  55. void invert();
  56. void transform(const Transform& b);
  57. /// @}
  58. /// @name Friends
  59. /// @{
  60. friend std::ostream& operator<<(std::ostream& s, const Transform& a);
  61. /// @}
  62. private:
  63. /// @name Data
  64. /// @{
  65. Vec3 origin; ///< The rotation
  66. Mat3 rotation; ///< The translation
  67. F32 scale; ///< The uniform scaling
  68. /// @}
  69. };
  70. /// @}
  71. } // end namespace
  72. #include "anki/math/Transform.inl.h"
  73. #endif