Skip to content

Commit

Permalink
Fixed look_at_rotation bug for 3 camera positions (#220)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
guanming001 authored and facebook-github-bot committed Jun 4, 2020
1 parent 5444c53 commit 4b78e95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pytorch3d/renderer/cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ def look_at_rotation(
msg = "Expected arg %s to have shape (N, 3); got %r"
raise ValueError(msg % (n, t.shape))
z_axis = F.normalize(at - camera_position, eps=1e-5)
x_axis = F.normalize(torch.cross(up, z_axis), eps=1e-5)
y_axis = F.normalize(torch.cross(z_axis, x_axis), eps=1e-5)
x_axis = F.normalize(torch.cross(up, z_axis, dim=1), eps=1e-5)
y_axis = F.normalize(torch.cross(z_axis, x_axis, dim=1), eps=1e-5)
R = torch.cat((x_axis[:, None, :], y_axis[:, None, :], z_axis[:, None, :]), dim=1)
return R.transpose(1, 2)

Expand Down

0 comments on commit 4b78e95

Please sign in to comment.