Skip to content

Commit 06a76ef

Browse files
alex-benefacebook-github-bot
authored andcommitted
Correct "fast" matrix_to_axis_angle near pi (#1953)
Summary: A continuation of #1948 -- this commit fixes a small numerical issue with `matrix_to_axis_angle(..., fast=True)` near `pi`. bottler feel free to check this out, it's a single-line change. Pull Request resolved: #1953 Reviewed By: MichaelRamamonjisoa Differential Revision: D70088251 Pulled By: bottler fbshipit-source-id: 54cc7f946283db700cec2cd5575cf918456b7f32
1 parent 2120573 commit 06a76ef

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

pytorch3d/transforms/rotation_conversions.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ def matrix_to_axis_angle(matrix: torch.Tensor, fast: bool = False) -> torch.Tens
542542
zeros = torch.zeros(3, dtype=matrix.dtype, device=matrix.device)
543543
omegas = torch.where(torch.isclose(angles, torch.zeros_like(angles)), zeros, omegas)
544544

545-
near_pi = torch.isclose(((traces - 1) / 2).abs(), torch.ones_like(traces)).squeeze(
546-
-1
547-
)
545+
near_pi = angles.isclose(angles.new_full((1,), torch.pi)).squeeze(-1)
548546

549547
axis_angles = torch.empty_like(omegas)
550548
axis_angles[~near_pi] = (

0 commit comments

Comments
 (0)