Skip to content

Commit

Permalink
Remove unused Matrix4::isEqual()
Browse files Browse the repository at this point in the history
Also add a simple test for Matrix4 equality using the regular operator==
method.
  • Loading branch information
Matthew Mott committed Mar 20, 2021
1 parent ef6e756 commit a0ecbc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
25 changes: 0 additions & 25 deletions libs/math/Matrix4.h
Expand Up @@ -420,11 +420,6 @@ class Matrix4
*/
bool operator!=(const Matrix4& other) const;

/**
* Returns true if self and other are element-wise equal within epsilon.
*/
bool isEqual(const Matrix4& other, double epsilon) const;

/**
* Returns true if this and the given matrix are exactly element-wise equal.
* This and the other matrix must be affine.
Expand Down Expand Up @@ -638,26 +633,6 @@ inline bool Matrix4::operator!=(const Matrix4& other) const
return !operator==(other);
}

inline bool Matrix4::isEqual(const Matrix4& other, double epsilon) const
{
return float_equal_epsilon(xx(), other.xx(), epsilon)
&& float_equal_epsilon(xy(), other.xy(), epsilon)
&& float_equal_epsilon(xz(), other.xz(), epsilon)
&& float_equal_epsilon(xw(), other.xw(), epsilon)
&& float_equal_epsilon(yx(), other.yx(), epsilon)
&& float_equal_epsilon(yy(), other.yy(), epsilon)
&& float_equal_epsilon(yz(), other.yz(), epsilon)
&& float_equal_epsilon(yw(), other.yw(), epsilon)
&& float_equal_epsilon(zx(), other.zx(), epsilon)
&& float_equal_epsilon(zy(), other.zy(), epsilon)
&& float_equal_epsilon(zz(), other.zz(), epsilon)
&& float_equal_epsilon(zw(), other.zw(), epsilon)
&& float_equal_epsilon(tx(), other.tx(), epsilon)
&& float_equal_epsilon(ty(), other.ty(), epsilon)
&& float_equal_epsilon(tz(), other.tz(), epsilon)
&& float_equal_epsilon(tw(), other.tw(), epsilon);
}

inline bool Matrix4::isAffineEqual(const Matrix4& other) const
{
return xx() == other.xx() &&
Expand Down
12 changes: 12 additions & 0 deletions test/math/Matrix4.cpp
Expand Up @@ -99,6 +99,18 @@ TEST(MathTest, ConstructMatrixByRows)
EXPECT_EQ(m.translation(), Vector3(0.34, 9, 20));
}

TEST(MathTest, MatrixEquality)
{
Matrix4 m1 = Matrix4::byRows(1, 2, 3.5, 4,
5, -6, 17, 800,
9.01, 10, 11, 12.4,
200, -10, 300, 400);
Matrix4 m2 = m1;
EXPECT_TRUE(m1 == m2);
EXPECT_TRUE(m1 != Matrix4::getIdentity());
EXPECT_TRUE(m2 != Matrix4::getIdentity());
}

TEST(MathTest, MatrixRotationAboutXDegrees)
{
double angle = 30.0;
Expand Down

0 comments on commit a0ecbc7

Please sign in to comment.