diff --git a/include/tz/core/matrix.hpp b/include/tz/core/matrix.hpp index 4a722a73d3..033fbe5d5c 100644 --- a/include/tz/core/matrix.hpp +++ b/include/tz/core/matrix.hpp @@ -5,15 +5,22 @@ namespace tz { + /** + * @ingroup tz_core_math + * @brief Represents the generic matrix. + * @internal + */ template requires std::integral || std::floating_point struct matrix { + /// Retrieve a matrix filled with zeroes. static constexpr matrix zero() { return matrix::filled(T{0}); } + /// Retrieve an identity matrix that represents no transform. static constexpr matrix iden() { auto ret = matrix::zero(); @@ -23,7 +30,8 @@ namespace tz } return ret; } - + + /// Retrieve a matrix filled with the given value. static constexpr matrix filled(T t) { matrix ret; @@ -43,7 +51,9 @@ namespace tz const T& operator()(std::size_t x, std::size_t y) const; T& operator()(std::size_t x, std::size_t y); + /// Create a matrix that causes the inverse transformation. Such that the product of this and the result are the identity matrix. matrix inverse() const; + /// Retrieve a copy of this matrix but with its rows and columns swapped. matrix transpose() const; // matrix-scalar diff --git a/include/tz/core/quaternion.hpp b/include/tz/core/quaternion.hpp index 3bacb8bea4..b3444f341e 100644 --- a/include/tz/core/quaternion.hpp +++ b/include/tz/core/quaternion.hpp @@ -5,21 +5,35 @@ namespace tz { + /** + * @ingroup tz_core_math + * @brief Quaternion. Represents a rotation in 3D space. + */ struct quat : public tz::v4f { + /// Retrieve the identity quaternion, that is - represents no transformation. static quat iden() { return {tz::v4f{0.0f, 0.0f, 0.0f, 1.0f}}; } quat() = default; + /// Create a quaternion directly from xyzw components. quat(tz::v4f vec); + /// Create a quaternion that represents a rotation about a certain axis. static quat from_axis_angle(tz::v3f axis, float angle); + /// Create a quaternion that represents a rotation equivalent to the provided euler angles. static quat from_euler_angles(tz::v3f euler_angles); + /// Create a rotation matrix that transforms identically to the quaternion. tz::m4f matrix() const; + /// Create a quaternion that causes the inverse transformation. Such that the product of this and the result are the identity quaternion. quat inverse() const; + /// Combine one quaternion with another, producing a result equal to applying both rotations. quat combine(const quat& rhs) const; + /// Rotate a 3D position by this quaternion. tz::v3f rotate(tz::v3f pos) const; + /// Retrieve a normalised copy of the quaternion. quat normalise() const; + /// Retrieve a quaternion that represents a spherical interpolation between this quaternion and another, based upon a given factor. quat slerp(const quat& rhs, float factor) const; quat& operator*=(const quat& rhs);