# Derive FOV from projection matrix? How?

This topic is 2941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi have a projection matrix being set up using a frustum function
void Frustum(float left, float right, float bottom, float top, float near_, float far_);

Within that i set up a projection matrix.

Based on the parameters provided, or the projection matrix i need to figure out the Field of View. I've been searching for a while now and can't seem to find the solution?
Does anyone know the magic formula?

##### Share on other sites

Hi have a projection matrix being set up using a frustum function
void Frustum(float left, float right, float bottom, float top, float near_, float far_);

Within that i set up a projection matrix.

Based on the parameters provided, or the projection matrix i need to figure out the Field of View. I've been searching for a while now and can't seem to find the solution?
Does anyone know the magic formula?

Basically you're just calculate the angle between the top of the window, the camera eye, and bottom of the window. Don't have any formulas on me though, I'm sure you can find one easy though.

##### Share on other sites
If you are not generating an off-center projection matrix, I think these two are equivalent:
http://msdn.microsof...7(v=vs.85).aspx

http://msdn.microsof...1(v=vs.85).aspx

Equalling the top-left element of the two matrix representations, you get 2*near/(right-left) == 1/tan(fovX/2). This gives
tan(fovX/2) == (right-left)/(2*near), or

fovX = 2*atan[ (right-left)/(2*near) ].

(as usual, double-check I didn't make a mistake)

##### Share on other sites
Thanks for all the reply's guys. I ended up solving the issue before i checked this thread.

I have a void setPerspective(float fov, float aspect, float near_, float far_); function as well, this setPerspective function actually calls the frustum function. in setPerspective i calculate the value for top like so:
float top = near_ * float(tanf(fov * 3.14159265f / 360.0f));
With a little bit of thinking i reversed that formula to
float FOV = float(atanf(top / near_)) * SSR_RAD_TO_DEG * 2.0f;
Inside of the Frustum function.

Thanks again everyone!

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 17
• 13
• 46