pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

Wrong documentation

Open amirhagai opened this issue 1 year ago • 1 comments

The documentation for the "get_projection_transform" function within the "FoVPerspectiveCameras" class, found in the "renderer/cameras.py" file, appears to contain an inconsistency regarding the calculation of s1 and s2. According to the documentation, the variables are defined as follows:

  • s1 is calculated as (1/\tan(fov/2)),
  • s2 is calculated as (1/(tan(fov/2) *aspect ratio)).

However, in practice, the definitions for s1 and s2 seem to be reversed:

for example -

self.compute_projection_matrix(znear, zfar, fov, aspect_ratio=1., degrees=degrees)

tensor([[[109.4238, 0.0000, 0.0000, 0.0000], [ 0.0000, 109.4238, 0.0000, 0.0000], [ 0.0000, 0.0000, 1.0101, -1.0101], [ 0.0000, 0.0000, 1.0000, 0.0000]]])

self.compute_projection_matrix(znear, zfar, fov, aspect_ratio=2., degrees=degrees)

tensor([[[ 54.7119, 0.0000, 0.0000, 0.0000], [ 0.0000, 109.4238, 0.0000, 0.0000], [ 0.0000, 0.0000, 1.0101, -1.0101], [ 0.0000, 0.0000, 1.0000, 0.0000]]])

amirhagai avatar Feb 25 '24 16:02 amirhagai

I think you're right - and that comment has always been the wrong way round. Do you want to send a PR to fix it?

bottler avatar Feb 26 '24 08:02 bottler