Example #1
0
    def test_from_euler_with_small_angles_approximation_jacobian_random(self):
        """Test the Jacobian of from_euler_with_small_angles_approximation."""
        x_init = test_helpers.generate_random_test_euler_angles(
            min_angle=-0.17, max_angle=0.17)
        x = tf.convert_to_tensor(value=x_init)

        y = rotation_matrix_3d.from_euler_with_small_angles_approximation(x)

        self.assert_jacobian_is_correct(x, x_init, y)
    def test_from_euler_with_small_angles_approximation_random(self):
        """Tests small_angles approximation by comparing to exact calculation."""
        # Only generate small angles. For a test tolerance of 1e-3, 0.16 was found
        # empirically to be the range where the small angle approximation works.
        random_euler_angles = test_helpers.generate_random_test_euler_angles(
            min_angle=-0.16, max_angle=0.16)

        exact_matrix = rotation_matrix_3d.from_euler(random_euler_angles)
        approximate_matrix = (
            rotation_matrix_3d.from_euler_with_small_angles_approximation(
                random_euler_angles))

        self.assertAllClose(exact_matrix, approximate_matrix, atol=1e-3)