1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef CORE_MATRIX_HPP
- #define CORE_MATRIX_HPP
- #include "core/math/Quaternion.hpp"
- #include "core/utils/ArrayString.hpp"
- namespace Core {
- class Matrix final {
- Vector4 data[4];
- public:
- Matrix();
- Matrix& unit();
- Matrix& set(int index, const Vector4& v);
- Matrix transpose();
- const float* getValues() const;
- Matrix& operator*=(const Matrix& other);
- Matrix operator*(const Matrix& other) const;
- Vector3 operator*(const Vector3& v) const;
- Matrix& scale(const Vector3& v);
- Matrix& scale(float f);
- Matrix& translate(const Vector3& v);
- Matrix& translateX(float tx);
- Matrix& translateY(float ty);
- Matrix& translateZ(float tz);
- Matrix& translateTo(const Vector3& v);
- Matrix& rotateX(float degrees);
- Matrix& rotateY(float degrees);
- Matrix& rotateZ(float degrees);
- Matrix& rotate(const Quaternion& q);
- template<typename String>
- check_return Error toString(String& s) const {
- CORE_RETURN_ERROR(s.append('['));
- CORE_RETURN_ERROR(s.append(data[0]));
- CORE_RETURN_ERROR(s.append(", "));
- CORE_RETURN_ERROR(s.append(data[1]));
- CORE_RETURN_ERROR(s.append(", "));
- CORE_RETURN_ERROR(s.append(data[2]));
- CORE_RETURN_ERROR(s.append(", "));
- CORE_RETURN_ERROR(s.append(data[3]));
- CORE_RETURN_ERROR(s.append("]"));
- return Error::NONE;
- }
- private:
- Matrix& rotate(float degrees, int a, int b);
- };
- }
- #endif
|