Skip to content

Commit 4b78e95

Browse files
guanming001facebook-github-bot
authored andcommitted
Fixed look_at_rotation bug for 3 camera positions (#220)
Summary: To address the issue #219 of Invalid rotation matrix when number of camera position is equal to 3 Pull Request resolved: #220 Reviewed By: bottler Differential Revision: D21877606 Pulled By: nikhilaravi fbshipit-source-id: f95ae44497cae33f2f0cff1b1718d866cf79bda1
1 parent 5444c53 commit 4b78e95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pytorch3d/renderer/cameras.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ def look_at_rotation(
916916
msg = "Expected arg %s to have shape (N, 3); got %r"
917917
raise ValueError(msg % (n, t.shape))
918918
z_axis = F.normalize(at - camera_position, eps=1e-5)
919-
x_axis = F.normalize(torch.cross(up, z_axis), eps=1e-5)
920-
y_axis = F.normalize(torch.cross(z_axis, x_axis), eps=1e-5)
919+
x_axis = F.normalize(torch.cross(up, z_axis, dim=1), eps=1e-5)
920+
y_axis = F.normalize(torch.cross(z_axis, x_axis, dim=1), eps=1e-5)
921921
R = torch.cat((x_axis[:, None, :], y_axis[:, None, :], z_axis[:, None, :]), dim=1)
922922
return R.transpose(1, 2)
923923

0 commit comments

Comments
 (0)