Reasonably-Good Bounding Sphere of an Affine-Transformed Sphere I have a unit sphere transformed by a given $4\times 4$ affine transform (it is a 3D transform; using homogenous coordinates with $w=1$ allows representing translation).

I now need to calculate a bounding sphere of this transformed sphere.  How can I do this?



For completeness, I should mention I've thought of some bad ways to do it.

For example, one could take the sphere's axis-aligned bounding box, transform that, and then compute the minimal bounding sphere of those 8 points.  This is unsatisfactory because the bounding sphere will be very coarse.  E.g. if the transform were the identity, we can see that the new bounding sphere will have $3 \sqrt{3} ~\times$ the volume.

So as additional requirements: the preferred method will produce a fairly tight bounding sphere and also be reasonably simple ($O(1)$ time, small constant).
Okay, well I thought about it some more, and it's actually pretty easy.  Here are some algorithms, all of which produce the optimal bounding sphere:


In your example, don't consider the axis-aligned box's corners.  Consider its face-centers.
As a refinement of this, forward transform the origin as well as the points $&lt;1,0,0&gt;, &lt;0,1,0&gt;, &lt;0,0,1&gt;$.  The transformed origin is the center of the new bounding sphere, and the longest vector from the transformed origin to one of those transformed points is the radius.
Decompose matrix into position/rotation/scale.  As a commenter mentioned one can use SVD, but because it's affine, there's also an easier way.  Then the radius of the bounding sphere is the max scaling along any axis, and the position is the translation (or you can find it by forward-transforming the origin).
Okay, well I thought about it some more, and it's actually pretty easy.  Here are some algorithms, all of which produce the optimal bounding sphere:


In your example, don't consider the axis-aligned box's corners.  Consider its face-centers.
As a refinement of this, forward transform the origin as well as the points $&lt;1,0,0&gt;, &lt;0,1,0&gt;, &lt;0,0,1&gt;$.  The transformed origin is the center of the new bounding sphere, and the longest vector from the transformed origin to one of those transformed points is the radius.
Decompose matrix into position/rotation/scale.  As a commenter mentioned one can use SVD, but because it's affine, there's also an easier way.  Then the radius of the bounding sphere is the max scaling along any axis, and the position is the translation (or you can find it by forward-transforming the origin).