Commit 4b78e95e authored by guanming001@e.ntu.edu.sg's avatar guanming001@e.ntu.edu.sg Committed by Facebook GitHub Bot
Browse files

Fixed look_at_rotation bug for 3 camera positions (#220)

Summary:
To address the issue https://github.com/facebookresearch/pytorch3d/issues/219 of Invalid rotation matrix when number of camera position is equal to 3
Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/220

Reviewed By: bottler

Differential Revision: D21877606

Pulled By: nikhilaravi

fbshipit-source-id: f95ae44497cae33f2f0cff1b1718d866cf79bda1
parent 5444c53c
...@@ -916,8 +916,8 @@ def look_at_rotation( ...@@ -916,8 +916,8 @@ def look_at_rotation(
msg = "Expected arg %s to have shape (N, 3); got %r" msg = "Expected arg %s to have shape (N, 3); got %r"
raise ValueError(msg % (n, t.shape)) raise ValueError(msg % (n, t.shape))
z_axis = F.normalize(at - camera_position, eps=1e-5) z_axis = F.normalize(at - camera_position, eps=1e-5)
x_axis = F.normalize(torch.cross(up, z_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), 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) R = torch.cat((x_axis[:, None, :], y_axis[:, None, :], z_axis[:, None, :]), dim=1)
return R.transpose(1, 2) return R.transpose(1, 2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment