View Full Version : How to set focal length in OpenGL^_^
04-05-2007, 12:06 AM
I was working on an algorithm. Focal length is an crucial parameter in my algorithm.
At first, I think the near_plane parameter which is used in gluPerspective(fovy, aspect, near_plane, far_plane) is related to focal length. But I tried and failed :(
Could anyone who have ever used this help me please? Thank you :)
You need to know more than focal length to set the corret FOV(which is what you can use with gluperspective(...) )
To calculate the FOV from a focal length you also need the projected area size ie. "frame size" you are using.
FOV (rectilinear) = 2 * arctan (frame size/(focal length * 2))
Here "frame size" refers to the dimension of the frame in the direction of the FOV, so for 35mm (which is 24mm x 36mm), frame size is 36mm for the horizontal FOV, 24mm for the vertical FOV and 43.25mm for the diagonal FOV
04-05-2007, 03:05 AM
Thank you, Mazy :) But I still have two questions to ask.
1, Is focal length equal to the distance from the viewpoint to the projection plane?
2, I can set the value of focal length by setting the value of fov, and fov is calculated through the formula that you posted, is that correct？
I am looking forward to your reply :)
Thanks again :)
Focal length is the number of millimeters from the lens to the focal point, it's a property of a lens so i don't think you find it directly equal to any number in OpenGL.
If you know what focal length your imaginary lens should have and what imaginary camera you want to simulate then you just calculate the FOV and use gluperspective. the Far and Near plane has nothing to do with that property, they are only there to clip anything outside those values, and thats not happening in real life.
04-05-2007, 06:19 AM
Thank you very much for your kindly instructions. But I am sorry because I think I confused focal length with the distance from viewpoint to projection plane. So I want to explain my question again.
I use OpenGL to realize my algorithm. I need to change the distance from the viewpoint to the projection plane. I believed it is same to the concept of focal length at first. But From your explanation, I think they are different.
So do you know how to change the distance from the viewpoint to the projection plane by using OpenGL? Thank you :) I hope you could help me :)
I appreciate your kindness very much :)
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.