From 8f6a2eda6197eae2b0757d5719dfa7ae47ec7e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20BR=C3=89GIER?= Date: Tue, 23 Apr 2024 14:56:24 +0200 Subject: [PATCH] Euler fix when single angle + README --- README.md | 1 + roma/euler.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bb1ad7f..4d95bad 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ rotvec = torch.randn(batch_shape + (3,)) q = roma.rotvec_to_unitquat(rotvec) R = roma.unitquat_to_rotmat(q) Rbis = roma.rotvec_to_rotmat(rotvec) +euler_angles = roma.unitquat_to_euler('xyz', q, as_tensor=True, degrees=True) # Regression of a rotation from an arbitrary input: # Special Procrustes orthonormalization of a 3x3 matrix diff --git a/roma/euler.py b/roma/euler.py index b6e05b3..5cba988 100644 --- a/roma/euler.py +++ b/roma/euler.py @@ -63,7 +63,10 @@ def euler_to_unitquat(convention: str, angles, degrees=False, normalize=True, dt raise ValueError("Invalid convention (expected format: 'xyz', 'zxz', 'XYZ', etc.).") q = roma.rotvec_to_unitquat(rotvec) unitquats.append(q) - return roma.quat_composition(unitquats, normalize=normalize) + if len(unitquats) == 1: + return unitquats[0] + else: + return roma.quat_composition(unitquats, normalize=normalize) def euler_to_rotvec(convention: str, angles, degrees=False, dtype=None, device=None): """