gluPerspective and field of view

Hi,
please excuse if this is not an advanced topic.

I am simulating a basketball with x and y cordinates at zero, and it is translating directly towards the eye, along the -z axis (i.e., it does not follow a parabolic path).

After each refresh, the basketball travels some distance along the z axis, depending on its speed. I want the basketball to be simulated at its actual visual angle for each distance on the z axis. So, if I am sitting at a fixed 60cm away from the screen, I want the basketball to be simulated at its correct visual angle.

I’ve looked at the red-book, which does discuss this issue (p. 133-134), but I do not understand how calculating the visual angle of an object that I know the size of (e.g., the diameter of a basketball is 24cm), is translated to the angle variable in gluPerspective.

For example, I know that if the basketball’s diameter (D) is 24cm, and its distance (Z) is 60cm, then its visual angle (theta) is:

theta = 2 * atan ((D*0.5)/Z)
= 2 * atan (12/60)
= 2 * 0.197
= 0.394 RADIANS
= 22.61 degrees

So I now know that the correct angle for the object at that distance, but how should this be used for the field of view (fovy) variable in gluPerspective(fovy, apect, Znear, Zfar)?

Can anyone provide an explanation please or point me to a good reference for this topic?

thanks in advance,
Simon

If I understood correctly, what you are trying to achieve, you should calculate your FOV angle based on your screen size, not based on the ball size. This way the fov angle will be a constant, but the size of the ball on the screen will increase, when the ball comes nearer to the viewpoint.

Eero

thanks epajarre,
I couldn’t get my head around the difference between actual and simulated FOV. would you measure screen size by hand, or would you use the manufacture’s specs, or is there a function that returns a better measurement of screen size? Also, is there a function that returns the screen sizes of objects so i could check that they are correct at their simulated distance?
thanks again,
Simon

If you want to calibrate it to your specific screen, just measuring it the old way sounds fine. Also if you can freeze your scene you can
also check your object dimensions with a ruler.

(I have used a 10 m tape measure with projection screen)

Eero

thanks euro.
Simon