From 5f3d3722b25c2a64fd7d82c323473198d72655b3 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sat, 28 Jan 2023 17:27:32 -0600 Subject: Add support for interpolating skewed transforms --- tests/core/math/test_transform_2d.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') 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); -- cgit v1.2.3