Matrix3x4.pkg 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. $#include "Matrix3x4.h"
  2. /// 3x4 matrix for scene node transform calculations.
  3. class Matrix3x4
  4. {
  5. public:
  6. /// Construct undefined.
  7. Matrix3x4();
  8. /// Copy-construct from another matrix.
  9. Matrix3x4(const Matrix3x4& matrix);
  10. /// Copy-construct from a 3x3 matrix and set the extra elements to identity.
  11. Matrix3x4(const Matrix3& matrix);
  12. /// Copy-construct from a 4x4 matrix which is assumed to contain no projection.
  13. Matrix3x4(const Matrix4& matrix);
  14. // Construct from values.
  15. Matrix3x4(float v00, float v01, float v02, float v03,
  16. float v10, float v11, float v12, float v13,
  17. float v20, float v21, float v22, float v23);
  18. /// Construct from translation, rotation and uniform scale.
  19. Matrix3x4(const Vector3& translation, const Quaternion& rotation, float scale);
  20. /// Construct from translation, rotation and nonuniform scale.
  21. Matrix3x4(const Vector3& translation, const Quaternion& rotation, const Vector3& scale);
  22. /// Test for equality with another matrix without epsilon.
  23. bool operator == (const Matrix3x4& rhs) const;
  24. /// Multiply a Vector3 which is assumed to represent position.
  25. Vector3 operator * (const Vector3& rhs) const;
  26. /// Multiply a Vector4.
  27. Vector3 operator * (const Vector4& rhs) const;
  28. /// Add a matrix.
  29. Matrix3x4 operator + (const Matrix3x4& rhs) const;
  30. /// Subtract a matrix.
  31. Matrix3x4 operator - (const Matrix3x4& rhs) const;
  32. /// Multiply with a scalar.
  33. Matrix3x4 operator * (float rhs) const;
  34. /// Multiply a matrix.
  35. Matrix3x4 operator * (const Matrix3x4& rhs) const;
  36. /// Multiply a 4x4 matrix.
  37. Matrix4 operator * (const Matrix4& rhs) const;
  38. /// Set translation elements.
  39. void SetTranslation(const Vector3& translation);
  40. /// Set rotation elements from a 3x3 matrix.
  41. void SetRotation(const Matrix3& rotation);
  42. /// Set scaling elements.
  43. void SetScale(const Vector3& scale);
  44. /// Set uniform scaling elements.
  45. void SetScale(float scale);
  46. /// Return the combined rotation and scaling matrix.
  47. Matrix3 ToMatrix3() const;
  48. /// Return the rotation matrix with scaling removed.
  49. Matrix3 RotationMatrix() const;
  50. /// Return the translation part.
  51. Vector3 Translation() const;
  52. /// Return the rotation part.
  53. Quaternion Rotation() const;
  54. /// Return the scaling part.
  55. Vector3 Scale() const;
  56. /// Test for equality with another matrix with epsilon.
  57. bool Equals(const Matrix3x4& rhs) const;
  58. /// Return decomposition to translation, rotation and scale.
  59. void Decompose(Vector3& translation, Quaternion& rotation, Vector3& scale) const;
  60. /// Return inverse.
  61. Matrix3x4 Inverse() const;
  62. float m00_ @ m00;
  63. float m01_ @ m01;
  64. float m02_ @ m02;
  65. float m03_ @ m03;
  66. float m10_ @ m10;
  67. float m11_ @ m11;
  68. float m12_ @ m12;
  69. float m13_ @ m13;
  70. float m20_ @ m20;
  71. float m21_ @ m21;
  72. float m22_ @ m22;
  73. float m23_ @ m23;
  74. /// Zero matrix.
  75. static const Matrix3x4 ZERO;
  76. /// Identity matrix.
  77. static const Matrix3x4 IDENTITY;
  78. };