ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Convert camera FOV to zoom distance?

FAQ   •   VIEW ALL
 Convert camera FOV to zoom distance? on Sep 5, 2013 at 6:17:26 pm

Hey guys, I'm working on a script to import 3D data from an XML file into after effects and I've hit a kind of silly problem... Basically all I'm trying to do is convert Field of View (degrees) to "zoom" (pixels) so that I can properly match an AE camera to one in my 3D app. I chose FOV because it is the most reliable value, it doesn't rely on the sensor size which can sometimes come out differently in AE vs whatever 3D app is exporting the XML (3DS Max in this particular case). Unfortunately the only value in After Effects I have access to is this somewhat obscure "zoom" value...

Thanks!
- Spencer

When I finish this script I'll be posting it for free, it allows you to export animated cameras, points and (eventually) lights from 3DS Max to AE! I wrote it so that anyone can code their own exporter from other 3D packages and AE just reads in an XML file to create it's scene.

 Re: Convert camera FOV to zoom distance?on Sep 5, 2013 at 6:41:21 pm

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

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: Convert camera FOV to zoom distance?on Sep 5, 2013 at 8:50:06 pm

Walter's expression is perfect for a horizontal FOV, which is generally the most common. However, the data from your 3D camera may be stored as a vertical or diagonal FOV in which case the expression will vary slightly:

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

Diagonal
``` w = thisComp.width; h = thisComp.height; d = Math.sqrt((w * w) / (h * h)); zoom = d /(2*Math.tan(degreesToRadians(FOV/2)));```

Darby Edelen

 Re: Convert camera FOV to zoom distance?on Sep 5, 2013 at 9:29:40 pm

[Darby Edelen] "Walter's expression is perfect for a horizontal FOV, which is generally the most common. However, the data from your 3D camera may be stored as a vertical or diagonal FOV in which case the expression will vary slightly:"

Great point. I was absolutely thinking in Ae terms here, but Smoke's camera uses a vertical FOV. That may apply for other ADSK products like 3ds Max, too.

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: Convert camera FOV to zoom distance?on Sep 5, 2013 at 10:49:06 pm

Thanks for the quick reply, looks like exactly what I need! Max does all 3, but in this case I'm exporting horizontal.

- Spencer