diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-26 13:44:41 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-26 13:44:41 +0200 |
commit | 3ec673085b161c6d0b134df11d2a63874066553d (patch) | |
tree | 2c27048e3c890ddf945b54d932c59ab856cdea10 /tests | |
parent | 1e4165ac603946afaf77c92c1a3d515432d3c747 (diff) | |
parent | 56806ffeed8f52781b460e328b347323b4dbaec0 (diff) | |
download | redot-engine-3ec673085b161c6d0b134df11d2a63874066553d.tar.gz |
Merge pull request #79523 from aaronfranke/is-conformal
Add `is_conformal` method to Basis and Transform2D
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/math/test_basis.h | 30 | ||||
-rw-r--r-- | tests/core/math/test_transform_2d.h | 30 |
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 |