Transform.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/MathCommonIncludes.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 float 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. float getScale() const;
  30. float& getScale();
  31. void setScale(const float 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 Transform combineTransformations(const Transform& a,
  44. const Transform& b); ///< @copybrief Math::combineTransformations
  45. /// Get the inverse transformation. Its faster that inverting a Mat4
  46. Transform getInverse() const;
  47. void invert();
  48. void transform(const Transform& b);
  49. /// @}
  50. /// @name Friends
  51. /// @{
  52. friend std::ostream& operator<<(std::ostream& s, const Transform& a);
  53. /// @}
  54. private:
  55. /// @name Data
  56. /// @{
  57. Vec3 origin; ///< The rotation
  58. Mat3 rotation; ///< The translation
  59. float scale; ///< The uniform scaling
  60. /// @}
  61. };
  62. /// @}
  63. } // end namespace
  64. #include "anki/math/Transform.inl.h"
  65. #endif