View Full Version : Camera Angle
07-27-2005, 10:36 AM
i want to write a mel/expression that keeps the object the same size in the cameraview, so u can change the Focal Length and the camera moves away/closer...
i found that the distance from the object can be determined through : sizeOfView/(2xtan(angleofview/2)) , where the sizeOfView means how much space u can see horizontally on your viewing plane
my problem : how do i get the angle of view ?
there is an angle value in the attribute editor but i guess no real angle attribute ...
i found a formula to calculate it (a=2xatan(S/(g-FL)/FL/g/2) with g=distance, fl= focal length, and S = ?! ....)
isnt there a more easy way to get the cameras angle of view?
07-28-2005, 05:30 PM
Here is the field of view formula:
FOV = 2 * arctan (frame size/(focal length * 2))
Maya's default camera has a 35mm Focal Length and above that is the Film Aperature (Frame Size) in maya units (cm). If you take the Horizontal Aperature and plug it in you should get the FOV horizontally - just make sure to convert your units from cm to mm.
I hope that's right.
07-29-2005, 02:58 AM
// Horizontal FOV for default 35mm maya camera is:
rad_to_deg(2 * atan(14.17 / (35 * 2)));
07-30-2005, 08:13 PM
thanks a lot!!
that really helped :)
rad_to_deg(2 * atan((cameraShape1.horizontalFilmAperture*25.4) / (cameraShape1.focalLength * 2)))
that is the final result :) horizontalFilmAperture is in inches ....
now i got to work out the rest ...
thanks again, will post result here when i am done :)
08-24-2005, 09:48 AM
Well i didnt get any further with the script :((
I thought this would do it :
//Camera FocalLength Script
float $fov = rad_to_deg(2 * atan((cameraShape1.horizontalFilmAperture*25.4) / (cameraShape1.focalLength * 2)));
camera1.translateZ = 4/(tan($fov/2));
but it doesnt !
Again : i want the camera move farther away from the object as the Focal Length increases, so the object size stays the same in the viewport ...
(i made it simple , so just the z translate changes, to test it)
Does anyone know why it doesnt work ? is it the way maya calculates its cameras ?
shouldnt it be : D=s/tan(a°) where D = distance from object , s = half the horizontal view area, a° = half the FOV .....
in my example above i used the view area of 8 for the script ... so s =4 ....
if anyone can help me , please do it ... its driving me nuts ....
08-24-2005, 09:48 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.