openglfrustum

What are the values of 8 coordinates of viewing frustum which has angle 'theta' at the origin?


Near clipping plane is at 'n' units distance. Far clipping plane is at 'f' units from origin. z-axis is pointing right screen, y-axis pointing up and x-axis pointing outside the screen. Assuming aspect ratio of 1.


Solution

  • Doing some basic trig you can get the width and height of the near and far plane, of the near plane they will be 2* tan(theta/2) * n and the far plane will be 2* tan(theta/2) * f

    So the 8 values will be

    (-n, n*tan(theta/2), n*tan(theta/2)), 
    (-n, -n*tan(theta/2), n*tan(theta/2)), 
    (-n, n*tan(theta/2), -n*tan(theta/2)), 
    (-n, -n*tan(theta/2), -n*tan(theta/2)), 
    (-f, f*tan(theta/2), f*tan(theta/2)), 
    (-f, -f*tan(theta/2), f*tan(theta/2)), 
    (-f, f*tan(theta/2), -f*tan(theta/2)), 
    (-f, -f*tan(theta/2), -f*tan(theta/2))