mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-22 07:10:34 +08:00
SO3 log map fix for singularity at PI
Summary: Fixes the case where the rotation angle is exactly 0/PI. Added a test for `so3_log_map(identity_matrix)`. Reviewed By: nikhilaravi Differential Revision: D21477078 fbshipit-source-id: adff804da97f6f0d4f50aa1f6904a34832cb8bfe
This commit is contained in:
committed by
Facebook GitHub Bot
parent
17ca6ecd81
commit
34a0df0630
@@ -152,11 +152,14 @@ def so3_log_map(R, eps: float = 0.0001):
|
||||
|
||||
phi = so3_rotation_angle(R)
|
||||
|
||||
phi_valid = torch.clamp(phi.abs(), eps) * phi.sign()
|
||||
phi_sin = phi.sin()
|
||||
|
||||
log_rot_hat = (phi_valid / (2.0 * phi_valid.sin()))[:, None, None] * (
|
||||
R - R.permute(0, 2, 1)
|
||||
phi_denom = (
|
||||
torch.clamp(phi_sin.abs(), eps) * phi_sin.sign()
|
||||
+ (phi_sin == 0).type_as(phi) * eps
|
||||
)
|
||||
|
||||
log_rot_hat = (phi / (2.0 * phi_denom))[:, None, None] * (R - R.permute(0, 2, 1))
|
||||
log_rot = hat_inv(log_rot_hat)
|
||||
|
||||
return log_rot
|
||||
|
||||
Reference in New Issue
Block a user