Notifications
Clear all

[Closed] Scripting: Camera lens value

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

thank you in advance

5 Replies

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

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
[B]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

thank you in advance [/B]

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

mhhhh perfect
thank you very much

Found this …on an XSI forum (so my colleague tells me… ugh!)

– 35mm lens equates to 36 mm aperture
– 121 mm for 5×4″ 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 = 2atan(A/(2F)) 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 5×4″ 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