For an axis-aligned ellipsoid, the equation is
$$ \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} = 1. $$
With $a=b$ this will give a spheroid with the $z$ axis as its symmetry axis. A spheroid which is centered at the origin but arbitrarily oriented can be described by its dimensions $a=b$ and $c$ and a vector $\vec r$ defining its orientation. So that vector $\vec r$ in the general case would correspond to the $z$-axis in the axis-aligned equation above.
I need to compute the normal of such a spheroid at any point on its surface. This can be done by computing the gradients of the equation. For an arbitrarily oriented spheroid, how to find the surface normals?
I have the following idea:
- Compute rotation matrix for transforming from $\vec r$ to $[0\;0\;1]$ using this.
- Compute the normals with the Cartesian aligned ellipsoid.
- Rotate the normal vector using $\vec r$.
Is there a better way to do this? For example, computing the normal directly on an arbitrarily oriented ellipsoid?