View Full Version : FovY (or Zoom) value

I'm not quite sure if this has been asked before - sorry if this is a repetition. And i do find it hard to express exactly what i'm looking for but here we go:

I compared OpenGL's projection of a 3D coordinate to the formula:

Sx = Cx + Fovy * (Vx / Vz)

Sy = Cy + Fovy * (Vy / Vz)

...and for some weirdo reason the projections aren't the same. Infact, they're way off. Now I do realize that the 'fovy' is an angle between 0 and 180; is some trigonomic conversion required for FovY?

Thanks for any advice,

-Brian

Overmind

10-11-2001, 12:03 PM

The formula you are using is probably wrong. It can't be right because of the following reasons:

1) FovY is the field of view for the Y direction, you have to calc FovX from FovY and the x/y ratio

2) FovY is an angle, that means you probably need to use trigonometric functions (sin, cos, tan) in the formula.

Update:

I just drew a few triangles on a sheet of paper and found out the real formula:

t = tan(FovY/2) * n

b = -t

r = t * w/h

l = -r

Sx = (2*n*Vx)*(f-n) / ((r-l)*(-2*f*n)*Vz)

Sy = (2*n*Vy)*(f-n) / ((t-b)*(-2*f*n)*Vz)

Where t, b, r, l are the top, bottom, right, left screen edges on the near clipping plane, f and n are the distances of the far and near clipping plane.

The first four formulas are just basic trigonometry that translates the parameters of gluPerspective into the parameters of glFrustum.

The other two formulas are taken from the redbook (more precise: App F, matrix for perspective projection).

[This message has been edited by Overmind (edited 10-11-2001).]

Hey thanks for the formulae, i'll see what i can do with them http://www.opengl.org/discussion_boards/ubb/wink.gif

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.