Going from a point in a sphere from a point in an ellipsoid

Given a certain vector $v$ on the surface of a sphere centered at $0$, I'm trying to find another vector $w$ such that $w$ and $v$ are colinear and $w$ is on the surface of an ellipsoid also centered at $0$. Having read the answer to this question before, I tried to normalize $v$, multiply it by the radius of the sphere that has the same volume as the ellipsoid (since the transformation that corresponds to the matrix preserves volume) and then, multiply that result by the inversion of the matrix that takes points from the ellipsoid to the sphere. This didn't work. I'd like to know why and what can I do to find $w$.

If $v=(v_1, v_2, v_3)$ and the equation of your ellipsoid is $$\frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} =1$$ you are looking for some $\lambda > 0$ such that $w=\lambda v$ lies on the ellipsoid. Well, you can solve for $\lambda$ in the equation $$\frac{(\lambda v_1)^2}{a^2} + \frac{(\lambda v_2)^2}{b^2} + \frac{(\lambda v_3)^2}{c^2} =1$$ getting $$\lambda = \sqrt{\frac{1}{\frac{v_1^2}{a^2} + \frac{v_2^2}{b^2} + \frac{v_3^2}{c^2}}}$$

• Is there a way to do this using only linear algebra? I'd like to avoid doing any other operations other than adding and multiplying. – Laura Feb 23 '16 at 15:23
• @Laura Perhaps if we knew why you wanted to do this only using linear algebra we could help. Some kind of software problem? – DanielV Feb 23 '16 at 16:30
• It's a software problem indeed :) I'm doing some calculations using points on the surface of the Earth in real time, so I need to go from any point on the surface of a spherically-modeled Earth to the corresponding point in an ellipsoidal Earth and I need to do so as fast as possible. – Laura Feb 23 '16 at 16:49

$$x_1{}^2 + y_1{}^2 + z_1{}^2 = r^2 \tag{T1}$$ $$\left(\frac{x_2}{A}\right)^2 + \left(\frac{y_2}{B}\right)^2 + \left(\frac{z_2}{C}\right)^2 = 1 \tag{T2}$$ $$\frac{x_2}{x_1} = \frac{y_2}{y_1} \tag{T3}$$ $$\frac{y_2}{y_1} = \frac{z_2}{z_1} \tag{T4}$$ $$\frac{z_2}{z_1} = \frac{x_2}{x_1} \tag{T5}$$

$x_1,~y_1,~z_1$ are known. $x_2,~y_2,~z_2$ are unknown.

To find one of the unknown, use (T3) to (T5) to eliminate the other 2 unknowns by plugging them into (T2).

$$\left(\frac{x_2}{A}\right)^2 + \left(\frac{x_2~y_1}{x_1~B}\right)^2 + \left(\frac{x_2~z_1}{x_1~C}\right)^2 = 1$$ $$\left(\frac{y_2~x_1}{y_1~A}\right)^2 + \left(\frac{y_2}{B}\right)^2 + \left(\frac{y_2~z_1}{y_1~C}\right)^2 = 1$$ $$\left(\frac{z_2~x_1}{z_1~A}\right)^2 + \left(\frac{z_2~y_1}{z_1~B}\right)^2 + \left(\frac{z_2}{C}\right)^2 = 1$$

Which is:

$$\left(\frac{1}{A}\right)^2 + \left(\frac{y_1}{x_1~B}\right)^2 + \left(\frac{z_1}{x_1~C}\right)^2 = x_2^{-2}$$ $$\left(\frac{x_1}{y_1~A}\right)^2 + \left(\frac{1}{B}\right)^2 + \left(\frac{z_1}{y_1~C}\right)^2 = y_2^{-2}$$ $$\left(\frac{x_1}{z_1~A}\right)^2 + \left(\frac{y_1}{z_1~B}\right)^2 + \left(\frac{1}{C}\right)^2 = z_2^{-2}$$

Which is:

$$x_2{}^2 = \frac{x_1{}^2}{(x_1/A)^2 + (y_1/B)^2 + (z_1/C)^2}$$ $$y_2{}^2 = \frac{y_1{}^2}{(x_1/A)^2 + (y_1/B)^2 + (z_1/C)^2}$$ $$z_2{}^2 = \frac{z_1{}^2}{(x_1/A)^2 + (y_1/B)^2 + (z_1/C)^2}$$

The constraint the $x_1$, $y_1$, and $z_1$ lie on a circle of radius $r$ doesn't actually seem to simplify the problem, depending on your purpose, it may as well be ignored.