1 00:00:00,000 --> 00:00:04,152 We have a camera that is looking towards a sphere. We would like 2 00:00:04,252 --> 00:00:09,268 to calculate the ideal distance so that the camera's view frustrum grazes our 3 00:00:09,368 --> 00:00:13,388 sphere. We shall first define the radius of the sphere as 'r'. 4 00:00:13,483 --> 00:00:16,816 We shall now place our camera and begin defining its 5 00:00:16,916 --> 00:00:20,976 frustrum. In this 2D simplification, the camera frustrum can be 6 00:00:21,076 --> 00:00:24,608 thought of as an isosceles triangle with the apex angle 7 00:00:24,708 --> 00:00:27,711 being our field of view, that we will name 'f'. 8 00:00:27,800 --> 00:00:31,458 We will now bisect our frustrum. One may be tempted to then 9 00:00:31,558 --> 00:00:35,789 simply use the camera right vector and solve for the camera distance 10 00:00:35,889 --> 00:00:40,121 x by using trigonometry, this however is incorrect, and will lead to 11 00:00:40,221 --> 00:00:44,580 our frustrum intersecting the sphere. As you can see this doesn't work 12 00:00:44,680 --> 00:00:47,956 the way we want it to, let's try something different. 13 00:00:49,050 --> 00:00:53,289 The correct approach is to use a vector orthogonal to the frustrum 14 00:00:53,389 --> 00:00:58,024 instead of using the camera's right vector. We can then use trigonometry 15 00:00:58,124 --> 00:01:01,838 to find X, which in this case will just be the hypotenuse.