Skip to content

Commit

Permalink
Euler fix when single angle + README
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain BRÉGIER committed Apr 23, 2024
1 parent 9f648f9 commit 8f6a2ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion roma/euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 8f6a2ed

Please sign in to comment.