@@ -234,7 +234,7 @@ def test_from_rotation_translation_jacobian_random(self):
234234 self .assert_jacobian_is_finite_fn (dual_quaternion .from_rotation_translation ,
235235 [rotation_init , translation_init ])
236236
237- def test_from_rotation_matrix_normalized_random (self ):
237+ def test_from_rotation_translation_normalized_random (self ):
238238 (euler_angles , translation
239239 ) = test_helpers .generate_random_test_euler_angles_translations ()
240240 rotation = quaternion .from_euler (euler_angles )
@@ -246,22 +246,19 @@ def test_from_rotation_matrix_normalized_random(self):
246246 dual_quaternion .is_normalized (random_dual_quaternion ),
247247 np .ones (shape = rotation .shape [:- 1 ] + (1 ,), dtype = bool ))
248248
249- def test_from_rotation_matrix_random (self ):
249+ def test_from_rotation_translation_random (self ):
250250 (euler_angles_gt , translation_gt
251251 ) = test_helpers .generate_random_test_euler_angles_translations ()
252252 rotation_gt = quaternion .from_euler (euler_angles_gt )
253253
254254 dual_quaternion_output = dual_quaternion .from_rotation_translation (
255255 rotation_gt , translation_gt )
256- dual_quaternion_real = dual_quaternion_output [..., 0 :4 ]
257- dual_quaternion_dual = dual_quaternion_output [..., 4 :8 ]
258- rotation = rotation_matrix_3d .from_quaternion (dual_quaternion_real )
259- translation = 2.0 * quaternion .multiply (
260- dual_quaternion_dual , quaternion .inverse (dual_quaternion_real ))
261- translation = translation [..., 0 :3 ]
256+
257+ rotation , translation = dual_quaternion .to_rotation_translation (
258+ dual_quaternion_output )
262259
263260 self .assertAllClose (rotation_matrix_3d .from_quaternion (rotation_gt ),
264- rotation )
261+ rotation_matrix_3d . from_quaternion ( rotation ) )
265262 self .assertAllClose (translation_gt , translation )
266263
267264 @flagsaver .flagsaver (tfg_add_asserts_to_graph = False )
@@ -286,7 +283,7 @@ def to_translation(input_dual_quaternion):
286283
287284 self .assert_jacobian_is_finite_fn (to_translation , [rnd_dual_quaternion ])
288285
289- def test_to_rotation_matrix_random (self ):
286+ def test_to_rotation_translation_random (self ):
290287 (euler_angles_gt , translation_gt
291288 ) = test_helpers .generate_random_test_euler_angles_translations ()
292289 rotation_gt = quaternion .from_euler (euler_angles_gt )
@@ -300,6 +297,39 @@ def test_to_rotation_matrix_random(self):
300297 rotation_matrix_3d .from_quaternion (rotation ))
301298 self .assertAllClose (translation_gt , translation )
302299
300+ def test_from_axis_angle_translation_normalized_random (self ):
301+ (random_axis ,
302+ random_angle ,
303+ random_translation
304+ ) = test_helpers .generate_random_test_axis_angle_translation ()
305+
306+ random_dual_quaternion = dual_quaternion .from_axis_angle_translation (
307+ random_axis ,
308+ random_angle ,
309+ random_translation )
310+
311+ self .assertAllEqual (
312+ dual_quaternion .is_normalized (random_dual_quaternion ),
313+ np .ones (shape = random_dual_quaternion .shape [:- 1 ] + (1 ,), dtype = bool ))
314+
315+ def test_from_axis_angle_translation_random (self ):
316+ (axis_gt ,
317+ angle_gt ,
318+ translation_gt
319+ ) = test_helpers .generate_random_test_axis_angle_translation ()
320+
321+ rotation_gt = quaternion .from_axis_angle (axis_gt , angle_gt )
322+ dual_quaternion_output = dual_quaternion .from_axis_angle_translation (
323+ axis_gt ,
324+ angle_gt ,
325+ translation_gt )
326+
327+ rotation , translation = dual_quaternion .to_rotation_translation (
328+ dual_quaternion_output )
329+
330+ self .assertAllClose (rotation_gt , rotation )
331+ self .assertAllClose (translation_gt , translation )
332+
303333
304334if __name__ == "__main__" :
305335 test_case .main ()
0 commit comments