MEL - Angle of View

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  02 February 2013
MEL - Angle of View

Hi there,
is there any way to read the Angle of View (instead of the Focal Lenght) of a camera via MEL or and expression? It seems there is no getAttr or setAttr for it.

If this is not possible, how would I calculate the AOV from the Focal Length?

Cheers, Florian
 
  02 February 2013
Sure:

You need to known factors: the focal length f and the size of the camera aperture d (actually the film/ccd sensor size, but in Maya this would be the effective aperture). By default, aperture is equal to a 35mm image. While there are actually 3 angles of view (vertical, horizontal and diagonal), Maya only shows us the horizontal angle, as calculated by the following formula:

angle of view = 2 x atan(d / (2xf));

In MEL:

float $d = 35;  // film width
float $f = 50;  // focal length
float $ratio = $d / (2 * $f);
float $a = 2 * atan($ratio); // angle in radians
$a = rad_to_deg($a); // angle in degrees


In Python:
import math

def aov(d,f):
	a = 2 * math.atan(float(d) / (2*float(f)))
	a = math.degrees(a)
	return a

a = aov(35,35)
print a


Note that Maya seems to use some rounding internally, so the resulting values are not exactly identical.
 
  02 February 2013
Vielen Dank.
Gonna try it tomorrow.

Cheers, Florian
 
  02 February 2013
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:52 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.