ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Calculate default camera zoom angle from comp resolution

FAQ   •   VIEW ALL
 Calculate default camera zoom angle from comp resolution on Jan 2, 2014 at 1:43:54 am

Hi All,

I'm hoping someone can help me out here, I'looking into the zoom settings on the AE camera and can't find any documentation on how AE calculates its default values.

Does anybody know what the formula is?

I'm building a camera rig which has a control for the zoom, all is fine until I change the resolution of the comp. Is there an expression that can calculate the default value of the zoom? If so, Ill then look at an offset slider for the camera rig.

Many thanks in advance, you guys constantly rock my world.

Brett

 Re: Calculate default camera zoom angle from comp resolutionon Jan 2, 2014 at 2:13:42 am

[Brett Morris] "I'm hoping someone can help me out here, I'm looking into the zoom settings on the AE camera and can't find any documentation on how AE calculates its default values. Does anybody know what the formula is?"

If you know the camera's FOV, you can calculate the zoom in pixels as follows:

`zoom = thisComp.width/(2*Math.tan(degreesToRadians(FOV/2)));`

You can also simply ask Ae for the camera's zoom value in your expression:

`zoom = parseFloat(thisComp.activeCamera.zoom);`

 Re: Calculate default camera zoom angle from comp resolutionon Jan 2, 2014 at 2:23:12 am

[Walter Soyka] "If you know the camera's FOV, you can calculate the zoom in pixels as follows:

Interesting, thanks for your response Walter.

Thats definitely in line of what I'm after, though how can you access the FOV from the expression? If there was a way of that being automated, that would be ideal for this rig.

Thanks again!

 Re: Calculate default camera zoom angle from comp resolutionon Jan 2, 2014 at 3:01:45 am

[Brett Morris] "Thats definitely in line of what I'm after, though how can you access the FOV from the expression? If there was a way of that being automated, that would be ideal for this rig."

Zoom and FOV are related (as you see in the formula above, by the comp width). If you change the zoom, you change the FOV. If you change the FOV, you change the zoom. In fact, if you look at the Ae camera options in the timeline, the zoom and the FOV are the same property.

If you want to get the zoom in pixels of the active camera in any comp, just use thisComp.activeCamera.zoom in your expression.

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events

 Re: Calculate default camera zoom angle from comp resolutionon Jan 2, 2014 at 3:47:28 am

The equation that Walter posted previously:

`zoom = thisComp.width/(2*Math.tan(degreesToRadians(FOV/2)));`

Can be solved for FOV like this (assume 'zoom' has been assigned the zoom value of the camera):

``` zoom * 2 * Math.tan(degreesToRadians(FOV/2)) = thisComp.width; Math.tan(degreesToRadians(FOV/2)) = thisComp.width / (2 * zoom); degreesToRadians(FOV/2) = Math.atan2(thisComp.width, 2 * zoom); FOV/2 = radiansToDegrees(Math.atan2(thisComp.width, 2 * zoom)); FOV = 2 * radiansToDegrees(Math.atan2(thisComp.width, 2 * zoom)); ```

Since we are using thisComp.width we are solving for the horizontal FOV.

However, what Walter keeps coming back to is that converting the camera zoom value into a FOV is likely not necessary as it will probably end up being converted back (perhaps even unknowingly) into a zoom value at some point. I've seen expressions that have 10 extra lines and 20 extra operations all to do unnecessary conversions from zoom to FOV back to zoom or worse.

The only likely reason I can see for having any conversion from FOV to zoom or vice versa is for allowing FOV input from/output to a user. Otherwise all calculations should probably be done with the zoom value.

To answer your original question the 'default' camera (the one that exists if you don't have a camera in the composition) has a horizontal FOV of about 39.6°. I'd recommend using the default zoom value though, which you can find this way:

`defaultCameraZoom = thisComp.width / 0.72;`

0.72 is the ratio of the default camera film back (36mm) divided by the default camera focal length (50mm). The triangle formed by the zoom and composition width values is a projection of the triangle formed by the film back and focal length. The ratios of the two triangles are the same.

This ratio only necessarily applies to the default camera (36mm film back / 50mm focal length).

Darby Edelen

 Re: Calculate default camera zoom angle from comp resolutionon Jan 8, 2014 at 4:27:29 am

Thanks Darby, I really have to buy you a beer sometime soon.

I was away from the computer over the weekend and am only now digesting it, it certainly answers my question... though, now I feel like I need to rethink my end goals with the rig.

Ill keep you updated with the progress

 Re: Calculate default camera zoom angle from comp resolutionon Jan 9, 2014 at 5:10:58 am

Sure thing. If you'd like additional help we're always here :)

Darby Edelen

 Re: Calculate default camera zoom angle from comp resolutionon Jan 12, 2014 at 7:12:33 pm

Hey Darby, I have another question...

I'm using a variable to control the FOV. It works great as resizing the comp size automatically adjusts the zoom distance. My only concern now is that when I change the Lens size in the camera settings, nothing changes. Would that be correct behavior of the camera?

Regards,
Brett

 Re: Calculate default camera zoom angle from comp resolutionon Jan 14, 2014 at 1:17:55 am

What do you mean by lens size? The focal length? The aperture? There's a lot of specific language surrounding the camera's attributes so please do be, erm, specific :)

Here's some more general information. The focal length and film back are related on one side of an identity equation to the zoom and composition size on the other:

Film Back / Focal Length = Composition Size / Zoom

So changing either the Focal Length or the Film Back will change the Zoom value if the Composition Size remains constant (which it does when editing the camera settings). This equation is true by definition.

The FOV is also related to the above in that:

Film Back / Focal Length = Composition Size / Zoom = 2 * tan(FOV / 2)

So changing the value of any of the ratios by modifying the numerator or denominator disproportionately will necessarily change the FOV.

For example, increasing the Zoom by 1.5x would decrease the FOV unless the Composition Size also increases by 1.5x or more. If the Composition size is increased 2x but the Zoom only by 1.5x then the FOV would increase (2 / 1.5 > 1). If the Zoom and Composition Size are both increased by 1.5x then the FOV will remain unchanged (1.5 / 1.5 = 1).

Every other camera attribute is unrelated to the field of view.

Darby Edelen