diff --git a/libs/math/Matrix4.h b/libs/math/Matrix4.h index 267616e73c..ed59a2bf45 100644 --- a/libs/math/Matrix4.h +++ b/libs/math/Matrix4.h @@ -136,8 +136,7 @@ class alignas(16) Matrix4 } /** - * \brief - * Construct a matrix containing the given elements. + * \brief Construct a matrix containing the given elements. * * The elements are specified column-wise, starting with the left-most * column. @@ -148,8 +147,7 @@ class alignas(16) Matrix4 double tx, double ty, double tz, double tw); /** - * \brief - * Construct a matrix containing the given elements. + * \brief Construct a matrix containing the given elements. * * The elements are specified row-wise, starting with the top row. */ @@ -211,26 +209,14 @@ class alignas(16) Matrix4 * Return columns of the matrix as vectors. * \{ */ - Vector3& xCol3Ref() - { - return reinterpret_cast(xx()); - } Vector3 xCol3() const { return Vector3(_transform.matrix().col(0).head(3)); } - Vector3& yCol3Ref() - { - return reinterpret_cast(yx()); - } Vector3 yCol3() const { return Vector3(_transform.matrix().col(1).head(3)); } - Vector3& zCol3Ref() - { - return reinterpret_cast(zx()); - } Vector3 zCol3() const { return Vector3(_transform.matrix().col(2).head(3)); diff --git a/test/math/Matrix4.cpp b/test/math/Matrix4.cpp index 47b14c3e31..649441a9ae 100644 --- a/test/math/Matrix4.cpp +++ b/test/math/Matrix4.cpp @@ -126,16 +126,6 @@ TEST(MatrixTest, AccessMatrixColumnVectors) EXPECT_EQ(m.zCol3(), Vector3(8, 7, 10)); EXPECT_EQ(m.tCol(), Vector4(-5, 13, 14, 3)); EXPECT_EQ(m.translation(), Vector3(-5, 13, 14)); - - // Write column values - m.xCol3Ref() = Vector3(0.1, 0.2, 0.3); - m.yCol3Ref() = Vector3(0.5, 0.6, 0.7); - m.zCol3Ref() = Vector3(0.9, 1.0, 1.1); - m.setTranslation({1.3, 1.4, 1.5}); - EXPECT_EQ(m, Matrix4::byColumns(0.1, 0.2, 0.3, 26, - 0.5, 0.6, 0.7, -100, - 0.9, 1.0, 1.1, 0.5, - 1.3, 1.4, 1.5, 3)); } TEST(MatrixTest, SetMatrixColumnVectors) @@ -165,6 +155,13 @@ TEST(MatrixTest, SetMatrixColumnVectors) -5, 14, 150, 678, 9, 600, 0.5, 2, 75, 0, 1, -9)); + + // Set translation column + m.setTranslation({-0.8, -6, 27}); + EXPECT_EQ(m, Matrix4::byRows(5, 27, -100, -0.8, + -5, 14, 150, -6, + 9, 600, 0.5, 27, + 75, 0, 1, -9)); } TEST(MatrixTest, MatrixRawArrayData)