# Calculating an axis aligned bounding box for a transformed sphere

I'm trying to understand the math behind this answer :

https://stackoverflow.com/questions/4368961/calculating-an-aabb-for-a-transformed-sphere/4369956#4369956

I've implemented it and it seems to work, but I don't know why ..

Can somebody point me to a definition of the dual of a conic and why it allows us to find the planes tangent to the tranformation ?

Thanks.

## migrated from mathoverflow.netSep 5 '13 at 17:36

This question came from our site for professional mathematicians.

The first trick is that if points are represented by homogeneous coordinates $\vec{p} = \begin{bmatrix}x & y & z & 1\end{bmatrix}^\mathrm{T}$, a plane can be represented by a row vector $\vec{q}^\mathrm{T} = \begin{bmatrix}a & b & c & d\end{bmatrix}$ such that

$$\vec{q} \cdot \vec{p} = a\,x + b\,y + c\,z + d = 0$$

is the plane equation. For a point $\vec{p}$ on the surface, the particular plane $\vec{q}^\mathrm{T} = \vec{p}^\mathrm{T}\,\mathbf{S}$ touches the surface at $\vec{p}$ since $\vec{q} \cdot \vec{p} = \vec{p}^\mathrm{T}\,\mathbf{S}\,\vec{p} = 0$.

In fact, this point is the only point of intersection, so $\vec{q}$ must be the tangent plane at that point. To see why, look at any point $\vec{p}' = \vec{p} + r\,\hat{r}$ that lies on the plane and the surface.

\begin{align*} \vec{p}'^\mathrm{T} \, \mathbf{S} \, \vec{p}' & = (\vec{p} + r\,\hat{r})^\mathrm{T} \, \mathbf{S} \, \vec{p}' \\ {} & = \vec{q}\cdot\vec{p}' + r\,\hat{r}^\mathrm{T} \, \mathbf{S} \, \vec{p}' \\ {} & = r \, (\vec{p}'^\mathrm{T} \, \mathbf{S} \, \hat{r})^\mathrm{T} \\ {} & = r \, \left((\vec{p} + r\,\hat{r}\right)^\mathrm{T} \, \mathbf{S} \, \hat{r})^\mathrm{T} \\ {} & = r^2 \, (\hat{r}^\mathrm{T} \, \mathbf{S} \, \hat{r})^\mathrm{T} \\ {} & = r^2 \, (\hat{r}^\mathrm{T} \, \mathbf{S} \, \hat{r}) \\ {} & = 0 \end{align*}

If $\hat{r}^\mathrm{T} \, \mathbf{S} \, \hat{r} = 0$, then the whole line $\vec{p} + t\,\hat{r}$ lies on the surface, but that can't be true since the surface is curved. Therefore $r = 0$ and $\vec{p}' = \vec{p}$.

That's all we need to prove the formula for the so-called dual,

\begin{align*} \vec{q}^\mathrm{T} \, \mathbf{S}^{-1} \, \vec{q} & = \vec{p}^\mathrm{T} \, \mathbf{S} \, \mathbf{S}^{-1} \, \mathbf{S} \, \vec{p} \\ {} & = \vec{p}^\mathrm{T} \, \mathbf{S} \, \vec{p} \\ {} & = 0. \end{align*}

By the way, I know these as quadric surfaces or quadratic forms. To me a conic section lies in the plane. Also, I wrote a blog post here that covers this topic and gives a simplified form for the bounding boxes that should be faster to calculate.
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}