#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(size_t 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 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 ErrorCode::NONE; } private: Matrix& rotate(float degrees, int a, int b); }; } #endif