Пример #1
0
  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)
Пример #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_2d()
    x_matrix = tf.convert_to_tensor(value=x_matrix_init)
    tensor_shape = x_matrix_init.shape[:-2] + (2,)
    x_point_init = np.random.uniform(size=tensor_shape)
    x_point = tf.convert_to_tensor(value=x_point_init)

    y = rotation_matrix_2d.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)
Пример #3
0
 def func(test_point, test_angle):
   random_matrix = rotation_matrix_2d.from_euler(test_angle)
   return rotation_matrix_2d.rotate(test_point, random_matrix)