Skip to content

Commit

Permalink
Remove unused BasicVector4::isEqual()
Browse files Browse the repository at this point in the history
This functionality is implemented for Vector4 by math::isNear(), which is now
tested by an additional unit test.
  • Loading branch information
Matthew Mott committed Sep 1, 2021
1 parent 5024bb0 commit 528c790
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
13 changes: 0 additions & 13 deletions libs/math/Vector4.h
Expand Up @@ -291,19 +291,6 @@ class BasicVector4
const BasicVector3<Element>& getVector3() const {
return *reinterpret_cast<const BasicVector3<Element>*>(_v);
}

/**
* Equality check with tolerance epsilon.
*/
template<typename OtherElement>
bool isEqual(const BasicVector4<OtherElement>& other, Element epsilon) const
{
return float_equal_epsilon(x(), other.x(), epsilon) &&
float_equal_epsilon(y(), other.y(), epsilon) &&
float_equal_epsilon(z(), other.z(), epsilon) &&
float_equal_epsilon(w(), other.w(), epsilon);
}

}; // BasicVector4

/// Multiply BasicVector4 with a scalar
Expand Down
15 changes: 14 additions & 1 deletion test/math/Vector.cpp
Expand Up @@ -96,7 +96,7 @@ TEST(MathTest, Vector3EqualityComparison)
EXPECT_NE(v1, v2);
}

TEST(MathTest, VectorEpsilonComparison)
TEST(MathTest, Vector3EpsilonComparison)
{
const Vector3 v(1, 8, 320);
const Vector3 increment(1e-8, 1e-7, 1e-8);
Expand All @@ -120,6 +120,19 @@ TEST(MathTest, Vector4EqualityComparison)
EXPECT_NE(v1, v2);
}

TEST(MathTest, Vector4EpsilonComparison)
{
const Vector4 v(256, -18, -0.5);
const Vector4 increment(1e-8, 1e-8, 1e-8, 1e-8);

EXPECT_NE(v, v + increment);
EXPECT_TRUE(math::isNear(v, v, 1e-10));
EXPECT_TRUE(math::isNear(v, v + increment, 1e-6));
EXPECT_TRUE(math::isNear(v, v - increment, 1e-6));
EXPECT_FALSE(math::isNear(v, v + increment, 1e-10));
EXPECT_FALSE(math::isNear(v, v - increment, 1e-10));
}

TEST(MathTest, NegateVector3)
{
Vector3 vec(5, 10, 125);
Expand Down

0 comments on commit 528c790

Please sign in to comment.