Suppose I have a radius for a spherical bounding box around a mesh.

My goal is to render the scene such as when the camera moves, the bounding box whose centre the camera look at, occupies always more or less the same space. To do so I'm changing the FOV of the camera when it moves, in particular I do:

FOV = 2 * arctan(radius/distance)

which is the value I feed to glm::perspective after the conversion to degrees.

whereas the distance is obtained by

distance = glm::distance(BBCentre, cameraPosition)

The problem is that when the distance becomes small it is like zooming out the object. For bigger distances, although the object does not occupy the portion of screen I was expecting, it doesn't move.

Am I doing something wrong here?


1 Answer 1


I believe I know why it's behaving strangely.

Here's a diagram I drew conceptually demonstrating the problem:

diagrammatically explained

I would solve the math for you too, but it should be easy enough from here. Give it a try and if you get stuck, just comment and ask.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .