summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2023-09-07 09:43:22 -0500
committerAaron Franke <arnfranke@yahoo.com>2023-09-13 17:20:30 -0500
commit56806ffeed8f52781b460e328b347323b4dbaec0 (patch)
treefbfaf77038aba9dac18b8db786b486a30c664175 /tests
parent3ed4497113fa10611b90290ce22a751fb9d26e2e (diff)
downloadredot-engine-56806ffeed8f52781b460e328b347323b4dbaec0.tar.gz
Add `is_conformal` method to Basis and Transform2D
Diffstat (limited to 'tests')
-rw-r--r--tests/core/math/test_basis.h30
-rw-r--r--tests/core/math/test_transform_2d.h30
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/core/math/test_basis.h b/tests/core/math/test_basis.h
index 0a34954bd3..fcac9a6231 100644
--- a/tests/core/math/test_basis.h
+++ b/tests/core/math/test_basis.h
@@ -296,6 +296,36 @@ TEST_CASE("[Basis] Finite number checks") {
"Basis with three components infinite should not be finite.");
}
+TEST_CASE("[Basis] Is conformal checks") {
+ CHECK_MESSAGE(
+ Basis().is_conformal(),
+ "Identity Basis should be conformal.");
+
+ CHECK_MESSAGE(
+ Basis::from_euler(Vector3(1.2, 3.4, 5.6)).is_conformal(),
+ "Basis with only rotation should be conformal.");
+
+ CHECK_MESSAGE(
+ Basis::from_scale(Vector3(-1, -1, -1)).is_conformal(),
+ "Basis with only a flip should be conformal.");
+
+ CHECK_MESSAGE(
+ Basis::from_scale(Vector3(1.2, 1.2, 1.2)).is_conformal(),
+ "Basis with only uniform scale should be conformal.");
+
+ CHECK_MESSAGE(
+ Basis(Vector3(3, 4, 0), Vector3(4, -3, 0.0), Vector3(0, 0, 5)).is_conformal(),
+ "Basis with a flip, rotation, and uniform scale should be conformal.");
+
+ CHECK_FALSE_MESSAGE(
+ Basis::from_scale(Vector3(1.2, 3.4, 5.6)).is_conformal(),
+ "Basis with non-uniform scale should not be conformal.");
+
+ CHECK_FALSE_MESSAGE(
+ Basis(Vector3(Math_SQRT12, Math_SQRT12, 0), Vector3(0, 1, 0), Vector3(0, 0, 1)).is_conformal(),
+ "Basis with the X axis skewed 45 degrees should not be conformal.");
+}
+
} // namespace TestBasis
#endif // TEST_BASIS_H
diff --git a/tests/core/math/test_transform_2d.h b/tests/core/math/test_transform_2d.h
index ca27776180..36d27ce7a9 100644
--- a/tests/core/math/test_transform_2d.h
+++ b/tests/core/math/test_transform_2d.h
@@ -130,6 +130,36 @@ TEST_CASE("[Transform2D] Finite number checks") {
"Transform2D with three components infinite should not be finite.");
}
+TEST_CASE("[Transform2D] Is conformal checks") {
+ CHECK_MESSAGE(
+ Transform2D().is_conformal(),
+ "Identity Transform2D should be conformal.");
+
+ CHECK_MESSAGE(
+ Transform2D(1.2, Vector2()).is_conformal(),
+ "Transform2D with only rotation should be conformal.");
+
+ CHECK_MESSAGE(
+ Transform2D(Vector2(1, 0), Vector2(0, -1), Vector2()).is_conformal(),
+ "Transform2D with only a flip should be conformal.");
+
+ CHECK_MESSAGE(
+ Transform2D(Vector2(1.2, 0), Vector2(0, 1.2), Vector2()).is_conformal(),
+ "Transform2D with only uniform scale should be conformal.");
+
+ CHECK_MESSAGE(
+ Transform2D(Vector2(1.2, 3.4), Vector2(3.4, -1.2), Vector2()).is_conformal(),
+ "Transform2D with a flip, rotation, and uniform scale should be conformal.");
+
+ CHECK_FALSE_MESSAGE(
+ Transform2D(Vector2(1.2, 0), Vector2(0, 3.4), Vector2()).is_conformal(),
+ "Transform2D with non-uniform scale should not be conformal.");
+
+ CHECK_FALSE_MESSAGE(
+ Transform2D(Vector2(Math_SQRT12, Math_SQRT12), Vector2(0, 1), Vector2()).is_conformal(),
+ "Transform2D with the X axis skewed 45 degrees should not be conformal.");
+}
+
} // namespace TestTransform2D
#endif // TEST_TRANSFORM_2D_H