コード例 #1
0
  def test_from_rotation_matrix_jacobian_random(self):
    """Test the Jacobian of the from_rotation_matrix function."""
    x_init = test_helpers.generate_random_test_rotation_matrix_3d()
    x = tf.convert_to_tensor(value=x_init)

    y = quaternion.from_rotation_matrix(x)

    self.assert_jacobian_is_finite(x, x_init, y)
コード例 #2
0
    def test_rotate_jacobian_random(self):
        """Test the Jacobian of the rotate function."""
        x_matrix_init = test_helpers.generate_random_test_rotation_matrix_3d()
        tensor_shape = x_matrix_init.shape[:-1]
        x_point_init = np.random.uniform(size=tensor_shape)

        self.assert_jacobian_is_correct_fn(rotation_matrix_3d.rotate,
                                           [x_point_init, x_matrix_init])
コード例 #3
0
    def test_inverse_jacobian_random(self):
        """Test the Jacobian of the inverse function."""
        x_init = test_helpers.generate_random_test_rotation_matrix_3d()
        x = tf.convert_to_tensor(value=x_init)

        y = rotation_matrix_3d.inverse(x)

        self.assert_jacobian_is_correct(x, x_init, y)
コード例 #4
0
  def test_from_rotation_matrix_normalized_random(self):
    """Tests that from_rotation_matrix produces normalized quaternions."""
    random_matrix = test_helpers.generate_random_test_rotation_matrix_3d()

    random_quaternion = quaternion.from_rotation_matrix(random_matrix)

    self.assertAllEqual(
        quaternion.is_normalized(random_quaternion),
        np.ones(shape=random_matrix.shape[:-2] + (1,), dtype=bool))
コード例 #5
0
  def test_from_rotation_matrix_random(self):
    """Tests that Euler angles can be retrieved from rotation matrices."""
    matrix = test_helpers.generate_random_test_rotation_matrix_3d()

    predicted_angles = euler.from_rotation_matrix(matrix)
    # There is not a unique mapping from rotation matrices to Euler angles. The
    # following constructs the rotation matrices from the `predicted_angles` and
    # compares them with `matrix`.
    reconstructed_matrices = rotation_matrix_3d.from_euler(predicted_angles)

    self.assertAllClose(reconstructed_matrices, matrix, rtol=1e-3)
コード例 #6
0
  def test_from_rotation_matrix_jacobian_random(self):
    """Test the Jacobian of the from_rotation_matrix function.

    Note:
      Preset angles are not tested as the gradient of tf.norm is NaN a 0.
    """
    x_init = test_helpers.generate_random_test_rotation_matrix_3d()

    self.assert_jacobian_is_finite_fn(
        lambda x: axis_angle.from_rotation_matrix(x)[0], [x_init])
    self.assert_jacobian_is_finite_fn(
        lambda x: axis_angle.from_rotation_matrix(x)[1], [x_init])
コード例 #7
0
    def test_rotate_jacobian_random(self):
        """Test the Jacobian of the rotate function."""
        x_matrix_init = test_helpers.generate_random_test_rotation_matrix_3d()
        x_matrix = tf.convert_to_tensor(value=x_matrix_init)
        tensor_shape = x_matrix.shape[:-1]
        x_point_init = np.random.uniform(size=tensor_shape)
        x_point = tf.convert_to_tensor(value=x_point_init)

        y = rotation_matrix_3d.rotate(x_point, x_matrix)

        self.assert_jacobian_is_correct(x_matrix, x_matrix_init, y)
        self.assert_jacobian_is_correct(x_point, x_point_init, y)
コード例 #8
0
    def test_from_rotation_matrix_jacobian_random(self):
        """Test the Jacobian of the from_rotation_matrix function.

    Note:
      Preset angles are not tested as the gradient of tf.norm is NaN a 0.
    """
        x_init = test_helpers.generate_random_test_rotation_matrix_3d()
        x = tf.convert_to_tensor(value=x_init)

        y_axis, y_angle = axis_angle.from_rotation_matrix(x)

        self.assert_jacobian_is_finite(x, x_init, y_axis)
        self.assert_jacobian_is_finite(x, x_init, y_angle)
コード例 #9
0
    def test_inverse_jacobian_random(self):
        """Test the Jacobian of the inverse function."""
        x_init = test_helpers.generate_random_test_rotation_matrix_3d()

        self.assert_jacobian_is_correct_fn(rotation_matrix_3d.inverse,
                                           [x_init])
コード例 #10
0
  def test_from_rotation_matrix_jacobian_random(self):
    """Test the Jacobian of the from_rotation_matrix function."""
    x_init = test_helpers.generate_random_test_rotation_matrix_3d()

    self.assert_jacobian_is_finite_fn(quaternion.from_rotation_matrix, [x_init])