diff --git a/doc/matrix-vector.dox b/doc/matrix-vector.dox index 81ecf0cf6..bb2162a0c 100644 --- a/doc/matrix-vector.dox +++ b/doc/matrix-vector.dox @@ -131,6 +131,17 @@ xyz.xy() *= 5; @endcode Color3 and Color4 name their components `rgba` instead of `xyzw`. +Matrix3 and Matrix4 have functions for accessing properties of given 2D/3D +transformation: +@code +Matrix4 a = Matrix4::translation(Vector3::yAxis(4.0f)); +Vector3 translation = a.translation(); + +Matrix3 b = Matrix3::rotation(deg(15.f)); +Matrix<2, float> rotationScaling = b.rotationScaling(); +Vector2 up = b.up(); +@endcode + For more involved operations with components there is the swizzle() function: @code Vector4 original(-1, 2, 3, 4); diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index c0687e0a0..cfe96ca3e 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -74,7 +74,18 @@ template class Matrix: public RectangularMatrix inline constexpr /*implicit*/ Matrix(const Vector& first, const U&... next): RectangularMatrix(first, next...) {} - /** @copydoc RectangularMatrix::RectangularMatrix(const RectangularMatrix&) */ + /** + * @brief Construct matrix from another of different type + * + * Performs only default casting on the values, no rounding or + * anything else. Example usage: + * @code + * Matrix<2, float> floatingPoint({1.3f, 2.7f}, + * {-15.0f, 7.0f}); + * Matrix<2, std::int8_t> integral(floatingPoint); + * // integral == {{1, 2}, {-15, 7}} + * @endcode + */ template inline constexpr explicit Matrix(const RectangularMatrix& other): RectangularMatrix(other) {} /** @brief Copy constructor */ diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 5a648fe7d..e7dd8ce9d 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -128,7 +128,7 @@ template class Matrix3: public Matrix<3, T> { /** @brief %Matrix from column vectors */ inline constexpr /*implicit*/ Matrix3(const Vector3& first, const Vector3& second, const Vector3& third): Matrix<3, T>(first, second, third) {} - /** @copydoc Matrix::Matrix(const RectangularMatrix&) */ + /** @copydoc Matrix::Matrix(const RectangularMatrix&) */ template inline constexpr explicit Matrix3(const RectangularMatrix<3, 3, U>& other): Matrix<3, T>(other) {} /** @brief Copy constructor */ diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 5ac26b89b..55f6a58ce 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -253,7 +253,7 @@ template class Matrix4: public Matrix<4, T> { /** @brief %Matrix from column vectors */ inline constexpr /*implicit*/ Matrix4(const Vector4& first, const Vector4& second, const Vector4& third, const Vector4& fourth): Matrix<4, T>(first, second, third, fourth) {} - /** @copydoc Matrix::Matrix(const RectangularMatrix&) */ + /** @copydoc Matrix::Matrix(const RectangularMatrix&) */ template inline constexpr explicit Matrix4(const RectangularMatrix<4, 4, U>& other): Matrix<4, T>(other) {} /** @brief Copy constructor */