Notifications
Clear all

[Closed] Match camera fov to rectangle

Given a rectangle, how would I match a camera’s fov to fit exactly? I’m setting the render width and height to match the size of the rectangle, but the FOV of the camera doesn’t match. This needs to be an orthographic projection.

Thanks.

2 Replies

You’ll need to use some trig.

You’ll need to calculate the horizontal angle of the camera based on the rectangle’s width and its distance from the camera. I.e. take the Tangent of the (width/2)/distance, since as we remember from high school algebra, tangent is opposite/adjacent.

horizontal FOV = 2tan((rectangle.width0.5)/camDistance)

Note: this is all from memory and untested, so someone please correct me if my math skills are a bit rusty.

 3ak

maybe: horizontal FOV = 2atan((rectangle.width0.5)/camDistance)