Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Precise definition of fovy

523 views
Skip to first unread message

Gib Bogle

unread,
Feb 2, 2003, 9:36:35 PM2/2/03
to
I'm having problems with a program in which I attempt to set fovy
precisely in order to ensure that an object in the scene just fits on
the screen (using gluPerspective()). What I'm finding is that my
computed fovy sometimes causes my object to be clipped slightly. This
makes me wonder if I'm computing my angles in exactly the right way. To
determine the "horizontal" angle associated with a point I effectively
construct two planes, one containing the "up" vector and the camera aim
vector, the other containing the "up" vector and the vector from the
camera position to the point. The angle between these two planes is the
horizontal angle for that point. The same procedure is followed for the
"vertical" angle, in this case using the vector orthogonal to the "up"
and aim vectors instead of the "up" vector. Depending on the relative
size of these two angles, fovy is either equal to the "vertical" angle
or equal to 0.75* the "horizontal" angle (I'm in full screen mode with
aspect ratio = 4/3).

Have I understood fovy correctly? Is there somewhere where this is
defined precisely (the Red Book definition is a bit vague)?

thanks
Gib

Andrew F. Vesper

unread,
Feb 2, 2003, 10:07:44 PM2/2/03
to
Gib Bogle wrote:
> ...Depending on the relative

> size of these two angles, fovy is either equal to the "vertical" angle
> or equal to 0.75* the "horizontal" angle (I'm in full screen mode with
> aspect ratio = 4/3).
>
> Have I understood fovy correctly? Is there somewhere where this is
> defined precisely (the Red Book definition is a bit vague)?

fovy is field-of-view-in-the-y-dimension -- that is, your
"vertical" angle.

--
Andy V (OpenGL Alpha Geek)
"In order to make progress, one must leave the door to the unknown ajar."
Richard P. Feynman, quoted by Jagdish Mehra in _The Beat of a Different Drum_.

OpenGL Technical FAQ: http://www.opengl.org/developers/faqs/technical.html

Gib Bogle

unread,
Feb 2, 2003, 10:46:22 PM2/2/03
to
"Andrew F. Vesper" wrote:
>
> Gib Bogle wrote:
> > ...Depending on the relative
> > size of these two angles, fovy is either equal to the "vertical" angle
> > or equal to 0.75* the "horizontal" angle (I'm in full screen mode with
> > aspect ratio = 4/3).
> >
> > Have I understood fovy correctly? Is there somewhere where this is
> > defined precisely (the Red Book definition is a bit vague)?
>
> fovy is field-of-view-in-the-y-dimension -- that is, your
> "vertical" angle.

Gee thanks ;). Apparently I failed to make it clear that my question
relates to determining this angle, given an arbitrary geometry. In the
sentence you quote I'm saying that I set fovy either equal to the
vertical angle, or to 3/4 of the horizontal angle, depending on their
ratio compared with the screen aspect ratio. The determination of the
angles is the crucial step.

Gib

Gib Bogle

unread,
Feb 3, 2003, 2:03:31 AM2/3/03
to

In case anyone is interested ... I finally figured out the explanation,
and it is a bit subtle.

The aspect ratio applies to the projected dimensions, not the angles. I
was scaling the horizontal angle by 3/4 to get fovy (when the horizontal
dimension is limiting). What I should have been doing is this
(horizontal and vertical angles are in radians):

aspect_ratio = 4.0/3.0;
halfwidth = tan(horizontal_angle/2);
halfheight = tan(vertical_angle/2);
if (halfwidth/halfheight > aspect_ratio) {
// use horizontal angle to set fovy
fovy = 2*atan(halfwidth/aspect_ratio);
} else {
// use vertical angle to set fovy
fovy = vertical_angle;
}
fovy = fovy*180/PI;

This works.

Gib

fungus

unread,
Feb 3, 2003, 2:11:34 AM2/3/03
to
Gib Bogle wrote:
>
> In case anyone is interested ... I finally figured out the explanation,
> and it is a bit subtle.
>
> The aspect ratio applies to the projected dimensions, not the angles. I
> was scaling the horizontal angle by 3/4 to get fovy (when the horizontal
> dimension is limiting). What I should have been doing is this
> (horizontal and vertical angles are in radians):
>

The FOV is applied in the vertical direction, yes.

--
<\___/>
/ O O \
\_____/ FTB.

Gib Bogle

unread,
Feb 3, 2003, 3:07:38 AM2/3/03
to

Not another one! The issue is not about fovy being vertical, it is how
to select fovy to maximize the image size on screen. Either the
vertical dimension or the horizontal dimension will be limiting. You
apparently didn't take the time to understand my posts. No reason why
you should, of course :)

Gib

Andrew F. Vesper

unread,
Feb 3, 2003, 7:04:51 PM2/3/03
to
Gib Bogle wrote:

> Not another one! The issue is not about fovy being vertical, it is how
> to select fovy to maximize the image size on screen. Either the
> vertical dimension or the horizontal dimension will be limiting. You
> apparently didn't take the time to understand my posts. No reason why
> you should, of course :)

Clearly you should have asked not about fovy, but about how
to calculate parameters to gluPerspective.

Gib Bogle

unread,
Feb 3, 2003, 7:37:58 PM2/3/03
to
"Andrew F. Vesper" wrote:
>
> Gib Bogle wrote:
>
> > Not another one! The issue is not about fovy being vertical, it is how
> > to select fovy to maximize the image size on screen. Either the
> > vertical dimension or the horizontal dimension will be limiting. You
> > apparently didn't take the time to understand my posts. No reason why
> > you should, of course :)
>
> Clearly you should have asked not about fovy, but about how
> to calculate parameters to gluPerspective.

I think one should read a post carefully before responding to it,
especially before responding in a way that treats the poster as an
idiot. fovy _is_ the relevant parameter to gluPerspective(). My
question was about determining the fovy value to use when the horizontal
field-of-view angle is limiting, and the key to my misunderstanding is
that the aspect ratio does not apply to field-of-view angles. For small
field-of-view angles the difference between applying the aspect ratio to
field-of-view angles and applying it to the dimensions of the image
projected on a view plane (i.e. the correct way) is very small, and so
it is possible to use it the wrong way and not notice the error. Since
I am trying to determine the minimum fovy very precisely to just fit the
object within the screen my error became obvious.

Gib

0 new messages