1
$\begingroup$

Sorry in advance for the terminology, I'm more programmer than mathematician.

I have an ellipsoid, quadratic surface, from a 3 axis magnetometer.
I know the semi principle axes for the ellipsoid, vectors r1, r2 and r3.
The orthogonal vectors r1, r2 and r3 do not align with the x,y,z world axes.
The ellipsoid is centred at 0,0,0.
Assuming vector lengths r1 > r2 > r3, I wish to "inflate" the ellipsoid into a sphere with radius equal to the length of r1, by scaling the ellipsoid along the r2 and r3 vectors.
The final sphere remains centred at 0,0,0.
There is no rotation of the final sphere with respect to the original ellipsoid, just an odd inflation.

Q: Is it possible to construct a single 3x3 matrix to do this scaling, without using 3(?) rotations to align the ellipsoid axes with the world xyz axes pre scaling and then undoing those rotations post scaling?

It is OK if this is not possible. It might save a bit of coding space.

Examples, explanations, etc. much appreciated.

This looks like the ellipsoid is already aligned with the world xyz axes.

This seems to have a rotation in the creation of the ellipsoid from sphere.

$\endgroup$
1
$\begingroup$

If $r_1,r_2,r_3$ are nonzero orthogonal column vectors, set $$M=\frac{1}{\|r_1\|^2}r_1^{\ } r_1^\top + \frac{\|r_1\|}{\|r_2\|^3}r_2^{\ } r_2^\top + \frac{\|r_1\|}{\|r_3\|^3}r_3^{\ } r_3^\top =\sum_{i=1}^3 \frac{\|r_1\|}{\|r_i\|^3}r_i^{\ } r_i^\top$$ Then $M$ has orthogonal eigenvectors $r_1,r_2,r_3$ and and $Mr_i = \frac{\|r_1\|}{\|r_i\|}r_i$, as desired. Furthermore, $M$ is symmetric.

$\endgroup$
2
  • 1
    $\begingroup$ A way to explain this is, when you multiply a vector $v$ by any the three matrices $\frac1{\|r_i\|^2}r_ir_i^T$ you get the component of $v$ in the direction of one of the orthonormal axes aligned with the axes of the ellipse; then you scale two of those components and put the results back together to get the desired vector. $\endgroup$
    – David K
    Aug 29 '17 at 12:39
  • 1
    $\begingroup$ This worked for me, once I'd remembered that a 3 element column vector multiplying a 3 element row vector produces a 3x3 matrix. Very elegant scaling without pre/post rotations. Thank you both, ccorn and David K $\endgroup$ Aug 29 '17 at 21:01
0
$\begingroup$

I don’t think that a rotation can be avoided, but since you’ve got the ellipsoid’s principal axes, you just need to normalize those vectors to get a transformation that will axis-align it.

The principal axes are mutually orthogonal, so the vectors $\mathbf u_i=\mathbf r_i/\|\mathbf r_i\|$, $i=1,2,3$ form an orthonormal basis for for $\mathbb R^3$. Since the columns of a transformation matrix are the images of the basis vectors, the transformation that maps from this basis to the standard basis is $$R=\begin{bmatrix}\mathbf u_1&\mathbf u_2&\mathbf u_3\end{bmatrix}.$$ This is an orthogonal matrix, which means that $R^{-1}=R^T$, the matrix that has these vectors as rows. So, one way to compute the scaling matrix is as the product $$S=R\Lambda R^T = \begin{bmatrix}\mathbf u_1&\mathbf u_2&\mathbf u_3\end{bmatrix} \begin{bmatrix}s_1&0&0\\0&s_2&0\\0&0&s_3\end{bmatrix} \begin{bmatrix}\mathbf u_1^T \\ \mathbf u_2^T \\ \mathbf u_3^T\end{bmatrix} = \begin{bmatrix}\mathbf u_1&\mathbf u_2&\mathbf u_3\end{bmatrix} \begin{bmatrix}s_1\mathbf u_1^T \\ s_2\mathbf u_2^T \\ s_3\mathbf u_3^T\end{bmatrix}.$$ For what you’re doing, the scale factors are $s_i=\|\mathbf r_1\|/\|\mathbf r_i\|$.

Note that $R$ might not preserve the chirality of the coordinate system, but since we transform back to the original coordinate system, these orientation changes cancel out.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.