[Math] Intersection of Ellipsoid with Ray

3dgeometrylinear algebramultivariable-calculus

Let $E$ be an ellipsoid centered at $p = (x,y,z) \in \mathbb{R}^3$ and
let $T:\mathbb{R}^3 \to \mathbb{R}^3 $ be a linear transformation
which transforms $E$ to a unit sphere.

Let $R$ be the ray $p_0 + tv$ ($v$ is normalized).

Assume we want to find the minimal $t \ge 0 $ if any such that $R$
intersects $E$.

I tried to define the ray $R_T$ to be $T(p_0) + tT(v)$ (where $T(v)$ is normalized) and find the minimal $t'\ge0$ if any such that $R_T$ intersects the unit sphere centered at $T(p)$.

If there was no intersection with $t\ge0$ then there is no intersection with $E$. Otherwise the new $t$ is the dot product of $v$ and $T^{-1}(t' \cdot T(v))$. Is this correct?

if $T(v)$ wasn't normalized in $R_T$ and we found the intersection with a sphere then the found $t$ would be the same for $E$ ?

Best Answer

You answer is indeed correct, and this is the foundation of "raytracing", a widely-used technique in graphics. Typically in graphics we are not given $T$ but rather its inverse (the "modeling transform"), so the formulas you'll see in graphics book will have a $T^{-1}$ in them ... but that's because they're talking about a slightly different problem.

If you want to generalize this to a more complicated transformation, $T$, that might include both translation and a linear part, there's a subtlety: in transforming the ray, you need to transform the start-point by $T$, but transform the direction vector by $DT$, the derivative of $T$. When $T$ is linear, the derivative is just $T$, so your formula works fine. When it's got a translation added, the derivative exactly deletes the translation, and the formula needs to take this into account.

(If you also want to transform the normal vector to the sphere, you need to transform that by the transpose of the derivative of $T$, more or less; it depends on how you intend to use the normal vector. (In particular, the transformation I mentioned may change its length, which is a problem if you need a unit vector!)