Skip to content

Instantly share code, notes, and snippets.

@RH2
Created May 7, 2022 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RH2/c8bb40b75c901c9bf486cfda40cf362b to your computer and use it in GitHub Desktop.
Save RH2/c8bb40b75c901c9bf486cfda40cf362b to your computer and use it in GitHub Desktop.
trig.vfl
float fovx; //field of view in X -
float fovy; //field of view in Y -
float aperature_x; //aperture in X 41.4214
float aperature_y; //aperture in Y -
float focal; //focal length 50
float resx; //pixel resolution in X 320
float resy; //pixel resolution in Y 243
float pixel_aspect; //pixel aspect (width/height)
//custom declarations
fovx = @f;
fovy = 0;
aperature_x = 1;
aperature_y = 1;
focal length = 1;
resx = @dimx;
resy = @dimy;
pixel_aspect = resx/resy;
fovx = 2 * atan( (aperature_x/2) / focal )
//tan(fovy/2) = (aperature_y/2) / focal
aperature_x/aperature_y = (resx * pixel_aspect) / resy
aperature_y = (resy*aperature_x) / (resx*pixel_aspect)
fovy = 2*atan( (aperature_y/2) / focal )
fovx = 2*atan( ( aperature_x / 2 ) / focal )
aperature_y = (resy * aperature_x) / (resx * pixel_aspect)
fovy = 2*atan( (aperature_y/2) / focal )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment