We have a camera that is looking towards a sphere. We would like
to calculate the ideal distance so that the camera's view frustrum grazes our
sphere. We shall first define the radius of the sphere as 'r'.
We shall now place our camera and begin defining its
frustrum. In this 2D simplification, the camera frustrum can be
thought of as an isosceles triangle with the apex angle
being our field of view, that we will name 'f'.
We will now bisect our frustrum. One may be tempted to then
simply use the camera right vector and solve for the camera distance
x by using trigonometry, this however is incorrect, and will lead to
our frustrum intersecting the sphere. As you can see this doesn't work
the way we want it to, let's try something different.
The correct approach is to use a vector orthogonal to the frustrum
instead of using the camera's right vector. We can then use trigonometry
to find X, which in this case will just be the hypotenuse.