# Perspective camera and field of view

I am trying to figure out where to position the camera to view a certain rectangle (of a planar slice) in my scene. I need to do this on the fly so I can’t just find a position that works, I need to be able to calculate it. When this didn’t seem to work I went back to a very basic test scene and it appears that I do not fully understand how it works. Here is a simple setup:

I have a 100100100 cube positioned at (50, 0, 0). This should mean that one of the faces have the four corners (0, -50, -50), (0, 50, -50), (0, 50, 50) and (0, -50, 50), ie a 100*100 square on the X=0 plane. Next I place a camera at (-x, 0, 0) looking in the direction of positive x, towards this face. The question is how far away, ie what must x be, to show the entire height of the face (but no more), like shown in this picture.

The vertical field of view for the camera is set to 90 degrees, so the angle up the the camera midline to the upper frustrum should be 45 degrees, and this should view half of the height of the cube face, which is 50, like in this delightful piece of coder art.

So basic trigonometry should indicate tan(45 deg) = 50 / x, which yields x = 50. However setting the camera x position to -50 does not show the full height of the cube, hand adjusting it seems to end up showing the full height at around -88. Am I completely misunderstanding the camera system?

Problem solved! Apparently, despite what the tooltip says, the FOV is horizontal.

Actually, FOV is calculated from the widest dimension of the render target (texture).

Say, you have a SceneCapture2D and a target texture. If that texture has dimensions w > h, then further growth of w won’t alter horizontal FOV (it remains the same for horizon). Otherwise, if h > w, then the FOV of your SceneCapture2D remains the same for the vertical view. You can test it playing with dimensions of the target texture.

I am having a similar problem. I would like to calculate the actual dimensions of my image captured from directly above the scene(aerial top down view). I can get the width (in meter, converting from unreal units) from your above formula using horizontal FOV. But I would also like to get the height of the image in meter. Can you please suggest how I can go about it?