Add euler to rotation matrix, grid flattening

This commit is contained in:
Piv
2021-08-10 20:39:52 +09:30
parent 8016f0f945
commit df1ac89a81
3 changed files with 110 additions and 52 deletions

View File

@@ -9,17 +9,20 @@ import warp
class MyTestCase(unittest.TestCase):
def test_euler_to_rotation_matrix(self):
# quarter rotation in every
x, y, z = tf.expand_dims(tf.expand_dims(tf.constant(np.pi / 2), 0), 0)
x = y = z = tf.expand_dims(tf.expand_dims(tf.constant(np.pi / 2), 0), 0)
x2 = y2 = z2 = tf.expand_dims(tf.expand_dims(tf.constant(np.pi / 4), 0), 0)
x_batch = tf.concat([x, x2], 0)
y_batch = tf.concat([y, y2], 0)
z_batch = tf.concat([z, z2], 0)
# TODO: Construct expected final rotation matrix, just 3x3 using numpy, so that we can do an
# elementwise comparison later. Probably also want to check the
rotation_matrices = warp.euler_to_rotation_matrix(x, y, z)
rotation_matrices = warp.euler_to_matrix(x_batch, y_batch, z_batch)
# old_rot = utils.euler2mat_noNDim(x_batch, y_batch, z_batch)
self.assertEqual(rotation_matrices.shape, [1, 3, 3])
rot_mat = rotation_matrices[0]
# TODO: Element-wise checks...
self.assertEqual(rotation_matrices.shape, [2, 3, 3])
def test_coordinates(self):
height = 1000