View Full Version : Scripting: Camera lens value
orpheo 05222003, 06:37 PM Does someone know the formula to get the lens value of a camera?
I know it depends on the horizontal FOV and the render aperture size, but I don't know the realtion between them... I found this in the reference :
**************************************************
Notes
The fov parameter value is the horizontal FOV in degrees.
The Vertical and Diagonal FOV and Lens values are based on the horizontal FOV and the current renderer Aperture Width.
You can use the following function to calculate the Vertical FOV from the Horizontal FOV:
Function:
fn GetCamVFOV theCamera =
( local r_aspect=(renderWidth as float)/renderHeight
2.*atan(tan(theCamera.fov/2.)/r_aspect)
)
*************************************************
but I'm not really good at mathematics :scream:
thank you in advance


LFShade
05222003, 07:39 PM
Not sure what you mean by "lens value." Do you mean like 35mm or 50mm, etc.? I probably don't have an answer for you, but I was just curous what you ultimately want to do with this information:)
RH
orpheo
05222003, 08:11 PM
Yes this is what I mean 35mm and so on.
I'm writting a script to manipulate the camera... the user would be able to change the FOV value (easy cos it is in the common properties of camera) but the lens is not reachable cos it's calculated in max pannel...
So I don't know how to read an change it through a script.
I have the same problem with the the reflect/refract material... I tried to do a script to create automatic skyboxes... but to generate the images of the cube you have to clic on the "render cubic map to file" button.... I never found how to reach it through script
Originally posted by orpheo
Does someone know the formula to get the lens value of a camera?
I know it depends on the horizontal FOV and the render aperture size, but I don't know the realtion between them...
*************************************************
but I'm not really good at mathematics :scream:
thank you in advance
Lens = 0.5 * (GetRendApertureWidth() / tan(FOV/2.0))
and backwards
FOV = 2.0* atan(GetRendApertureWidth()/Lens*0.5)
where
Lens is in mm
FOV is in degrees
Will add this to the MXS Help notes next time  it comes up quite often...
Cheers,
Bobo
orpheo
05232003, 11:39 PM
:)
mhhhh perfect
thank you very much
Alex Morris
05282003, 03:58 PM
Found this ...........on an XSI forum (so my colleague tells me.... ugh!)
 35mm lens equates to 36 mm aperture
 121 mm for 5x4" camera (estimate)
 VX2000 is 1/3" for the Aperture i.e. the CCD dimension
A = 0.036 as float  aperture dimension eg. 35 mm lens
F = .050 as float  Lens value (in mm)
fov = 2*atan(A/(2*F)) as float
print fov

This will give you a FOV for a 35mm camera. Most other formats give a 35mm equivalent. The important bit is the aperture. I've included an estimate for 5x4" format, and a Canon VX1000 which we use most of the time. Dont have figures for movie cameras and all the thousands of others out there though
CGTalk Moderation
01152006, 06:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©20002015, Jelsoft Enterprises Ltd.