Minimum Bounding Sphere for Frustum

I was in need to create a minimum bounding sphere for a frustum (truncated pyramid). The easiest way is to find the "center" of this pyramid. I got it by calculating the middle point of "the center of the near plane" and "the center of the far plane". The radius will be the length between this middle point and one of the vertices of the far plane. This works however, this is not an optimal bounding sphere for frustum.

I sat down and tried to figure out this problem. It turns out there is a simple way of doing this. Since the frustum is created with perspective projection in mind, this frustum is symmetrical. Furthermore, if we temporarily forget about the aspect ratio, the problem can be reduced into 2D problem: "Given an isosceles trapezoid, find the circumscribed circle".

I got the image from The first thing to realize is that the center of the enclosing circle is the intersection of the bisecting lines of each side.

If the length of the parallel sides are a (short) and b (long) and the height is h, and we want to find the length of CD, we can construct two equations:

AB^2 + BC^2 = AC^2
CD^2 + DE^2 = CE^2

Since AC and CE and essentially the radius of the circle, they should be the same. So we are left with:

(\frac{a}{2})^2 + (h - CD)^2 = (\frac{b}{2})^2 + (CD)^2

Solve the equation and you will get

CD = \frac{ h + \frac{(a - b)*(a + b)}{(4*h)} }{2}

I will left the reader with the exercise of finding the minimum bounding sphere of a frustum. It should be straightforward.


Popular posts from this blog

GDC 2015 Links

D3D11 Compute Shader - Part 1

Mapping Square Texture to Trapezoid / Quadrilateral