@@ -107,6 +107,35 @@ TEST_CASE("[Transform3D] Finite number checks") {
107107 " Transform3D with two components infinite should not be finite." );
108108}
109109
110+ TEST_CASE (" [Transform3D] Rotate around global origin" ) {
111+ // Start with the default orientation, but not centered on the origin.
112+ // Rotating should rotate both our basis and the origin.
113+ Transform3D transform = Transform3D ();
114+ transform.origin = Vector3 (0 , 0 , 1 );
115+
116+ Transform3D expected = Transform3D ();
117+ expected.origin = Vector3 (0 , 0 , -1 );
118+ expected.basis [0 ] = Vector3 (-1 , 0 , 0 );
119+ expected.basis [2 ] = Vector3 (0 , 0 , -1 );
120+
121+ const Transform3D rotated_transform = transform.rotated (Vector3 (0 , 1 , 0 ), Math_PI);
122+ CHECK_MESSAGE (rotated_transform.is_equal_approx (expected), " The rotated transform should have a new orientation and basis." );
123+ }
124+
125+ TEST_CASE (" [Transform3D] Rotate in-place (local rotation)" ) {
126+ // Start with the default orientation.
127+ // Local rotation should not change the origin, only the basis.
128+ Transform3D transform = Transform3D ();
129+ transform.origin = Vector3 (1 , 2 , 3 );
130+
131+ Transform3D expected = Transform3D ();
132+ expected.origin = Vector3 (1 , 2 , 3 );
133+ expected.basis [0 ] = Vector3 (-1 , 0 , 0 );
134+ expected.basis [2 ] = Vector3 (0 , 0 , -1 );
135+
136+ const Transform3D rotated_transform = Transform3D (transform.rotated_local (Vector3 (0 , 1 , 0 ), Math_PI));
137+ CHECK_MESSAGE (rotated_transform.is_equal_approx (expected), " The rotated transform should have a new orientation but still be based on the same origin." );
138+ }
110139} // namespace TestTransform3D
111140
112141#endif // TEST_TRANSFORM_3D_H
0 commit comments