Matrix.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef MATRIX_H
  2. #define MATRIX_H
  3. #include "math/Quaternion.h"
  4. #include "utils/StringBuffer.h"
  5. class Matrix final {
  6. Vector4 data[4];
  7. Matrix& rotate(float degrees, int a, int b);
  8. public:
  9. Matrix();
  10. Matrix& unit();
  11. Matrix& set(int index, const Vector4& v);
  12. Matrix transpose();
  13. const float* getValues() const;
  14. Matrix& operator*=(const Matrix& other);
  15. Matrix operator*(const Matrix& other) const;
  16. Vector3 operator*(const Vector3& v) const;
  17. Matrix& scale(const Vector3& v);
  18. Matrix& scale(float f);
  19. Matrix& translate(const Vector3& v);
  20. Matrix& translateX(float tx);
  21. Matrix& translateY(float ty);
  22. Matrix& translateZ(float tz);
  23. Matrix& translateTo(const Vector3& v);
  24. Matrix& rotateX(float degrees);
  25. Matrix& rotateY(float degrees);
  26. Matrix& rotateZ(float degrees);
  27. Matrix& rotate(const Quaternion& q);
  28. template<int L>
  29. void toString(StringBuffer<L>& s) const {
  30. s.append('[').append(data[0]).append(", ");
  31. s.append(data[1]).append(", ");
  32. s.append(data[2]).append(", ");
  33. s.append(data[3]).append("]");
  34. }
  35. };
  36. #endif