def test_inverse_jacobian_random(self): """Test the Jacobian of the inverse function.""" x_init = test_helpers.generate_random_test_rotation_matrix_2d() x = tf.convert_to_tensor(value=x_init) y = rotation_matrix_2d.inverse(x) self.assert_jacobian_is_correct(x, x_init, y)
def test_inverse_random(self): """Checks that inverting rotated points results in no transformation.""" random_euler_angles = test_helpers.generate_random_test_euler_angles( dimensions=1) tensor_shape = random_euler_angles.shape[:-1] random_matrix = rotation_matrix_2d.from_euler(random_euler_angles) random_point = np.random.normal(size=tensor_shape + (2,)) rotated_random_points = rotation_matrix_2d.rotate(random_point, random_matrix) predicted_invert_random_matrix = rotation_matrix_2d.inverse(random_matrix) predicted_invert_rotated_random_points = rotation_matrix_2d.rotate( rotated_random_points, predicted_invert_random_matrix) self.assertAllClose( random_point, predicted_invert_rotated_random_points, rtol=1e-6)