Math/Plane: Rename Distance method to SignedDistance

This commit is contained in:
SirLynix
2023-06-22 17:56:18 +02:00
parent 8481cc7c15
commit b2538028b4
6 changed files with 29 additions and 48 deletions

View File

@@ -19,30 +19,30 @@ SCENARIO("Plane", "[MATH][PLANE]")
AND_THEN("They have the same distance from the same point")
{
Nz::Vector3f point(-2.f, 3.f, 1.f);
REQUIRE(firstPlane.Distance(point) == Catch::Approx(secondPlane.Distance(point)));
REQUIRE(firstPlane.Distance(-2.f, 3.f, 1.f) == Catch::Approx(0.1547f));
REQUIRE(firstPlane.SignedDistance(point) == Catch::Approx(secondPlane.SignedDistance(point)));
REQUIRE(firstPlane.SignedDistance({ -2.f, 3.f, 1.f }) == Catch::Approx(0.1547f));
}
AND_THEN("Distance between Plane (0, 1, 0), distance 1 and point (0, 2, 0) should be 1")
{
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1.f).Distance(Nz::Vector3f::UnitY() * 2.f) == Catch::Approx(1.f));
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1.f).SignedDistance(Nz::Vector3f::UnitY() * 2.f) == Catch::Approx(1.f));
}
AND_THEN("Distance between Plane (0, 1, 0), distance 5 and point (0, 2, 0) should be -3")
{
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 5.f).Distance(Nz::Vector3f::UnitY() * 2.f) == Catch::Approx(-3.f));
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 5.f).SignedDistance(Nz::Vector3f::UnitY() * 2.f) == Catch::Approx(-3.f));
}
AND_THEN("Distance between Plane (0, 1, 0), distance 1000 and point (0, 500, 0) and (0, 1500, 0)")
{
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).Distance(Nz::Vector3f::UnitY() * 500.f) == Catch::Approx(-500.f));
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).Distance(Nz::Vector3f::UnitY() * 1500.f) == Catch::Approx(500.f));
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).SignedDistance(Nz::Vector3f::UnitY() * 500.f) == Catch::Approx(-500.f));
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).SignedDistance(Nz::Vector3f::UnitY() * 1500.f) == Catch::Approx(500.f));
}
AND_THEN("Distance between Plane (0, -1, 0), distance -1000 and point (0, 500, 0) and (0, 1500, 0)")
{
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).Distance(Nz::Vector3f::UnitY() * 500.f) == Catch::Approx(500.f));
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).Distance(Nz::Vector3f::UnitY() * 1500.f) == Catch::Approx(-500.f));
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).SignedDistance(Nz::Vector3f::UnitY() * 500.f) == Catch::Approx(500.f));
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).SignedDistance(Nz::Vector3f::UnitY() * 1500.f) == Catch::Approx(-500.f));
}
}