diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2023-01-28 17:27:32 -0600 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2023-01-28 18:28:42 -0600 |
commit | 5f3d3722b25c2a64fd7d82c323473198d72655b3 (patch) | |
tree | 9e948294ca5c4ce37d132466ac55c2b497453ebc /tests/core | |
parent | 218bef90af2091afde3b1be816c87286c194a2a8 (diff) |
Add support for interpolating skewed transforms
Diffstat (limited to 'tests/core')
-rw-r--r-- | tests/core/math/test_transform_2d.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/core/math/test_transform_2d.h b/tests/core/math/test_transform_2d.h index dc2b6e2ba8..ca27776180 100644 --- a/tests/core/math/test_transform_2d.h +++ b/tests/core/math/test_transform_2d.h @@ -84,6 +84,19 @@ TEST_CASE("[Transform2D] rotation") { CHECK(orig.rotated_local(phi) == orig * R); } +TEST_CASE("[Transform2D] Interpolation") { + Transform2D rotate_scale_skew_pos = Transform2D(Math::deg_to_rad(170.0), Vector2(3.6, 8.0), Math::deg_to_rad(20.0), Vector2(2.4, 6.8)); + Transform2D rotate_scale_skew_pos_halfway = Transform2D(Math::deg_to_rad(85.0), Vector2(2.3, 4.5), Math::deg_to_rad(10.0), Vector2(1.2, 3.4)); + Transform2D interpolated = Transform2D().interpolate_with(rotate_scale_skew_pos, 0.5); + CHECK(interpolated.get_origin().is_equal_approx(rotate_scale_skew_pos_halfway.get_origin())); + CHECK(interpolated.get_rotation() == doctest::Approx(rotate_scale_skew_pos_halfway.get_rotation())); + CHECK(interpolated.get_scale().is_equal_approx(rotate_scale_skew_pos_halfway.get_scale())); + CHECK(interpolated.get_skew() == doctest::Approx(rotate_scale_skew_pos_halfway.get_skew())); + CHECK(interpolated.is_equal_approx(rotate_scale_skew_pos_halfway)); + interpolated = rotate_scale_skew_pos.interpolate_with(Transform2D(), 0.5); + CHECK(interpolated.is_equal_approx(rotate_scale_skew_pos_halfway)); +} + TEST_CASE("[Transform2D] Finite number checks") { const Vector2 x(0, 1); const Vector2 infinite(NAN, NAN); |