Implement Vector2i/3i/4i methods: distance_to and distance_squared_to

This commit is contained in:
Jakub Marcowski
2023-10-11 12:04:57 +02:00
parent 9957f1ad4e
commit cb954c6bab
13 changed files with 168 additions and 0 deletions

View File

@@ -87,6 +87,12 @@ TEST_CASE("[Vector2i] Length methods") {
CHECK_MESSAGE(
vector2.length() == doctest::Approx(36.05551275463989293119),
"Vector2i length should work as expected.");
CHECK_MESSAGE(
vector1.distance_squared_to(vector2) == 500,
"Vector2i distance_squared_to should work as expected and return exact result.");
CHECK_MESSAGE(
vector1.distance_to(vector2) == doctest::Approx(22.36067977499789696409),
"Vector2i distance_to should work as expected.");
}
TEST_CASE("[Vector2i] Operators") {

View File

@@ -90,6 +90,12 @@ TEST_CASE("[Vector3i] Length methods") {
CHECK_MESSAGE(
vector2.length() == doctest::Approx(53.8516480713450403125),
"Vector3i length should work as expected.");
CHECK_MESSAGE(
vector1.distance_squared_to(vector2) == 1400,
"Vector3i distance_squared_to should work as expected and return exact result.");
CHECK_MESSAGE(
vector1.distance_to(vector2) == doctest::Approx(37.41657386773941385584),
"Vector3i distance_to should work as expected.");
}
TEST_CASE("[Vector3i] Operators") {

View File

@@ -90,6 +90,12 @@ TEST_CASE("[Vector4i] Length methods") {
CHECK_MESSAGE(
vector2.length() == doctest::Approx(73.4846922835),
"Vector4i length should work as expected.");
CHECK_MESSAGE(
vector1.distance_squared_to(vector2) == 3000,
"Vector4i distance_squared_to should work as expected.");
CHECK_MESSAGE(
vector1.distance_to(vector2) == doctest::Approx(54.772255750517),
"Vector4i distance_to should work as expected.");
}
TEST_CASE("[Vector4i] Operators") {