I've been googling, searching forums and looking in my old algebra/trig books to try to understand how to find the end points to the major and minor axis of an ellipse given the end points of two conjugate diameters (assume ellipse centered at the origin). I want to be able to recast an ellipse given that data into a form acceptable for use in an SVG diagram which requires the major(x) and minor(y) axis radii. I can calculate any rotation necessary from the major axis end point.
See for example the below image. I have conjugate points P and Q and need to find (a) and (b). Example showing conjugate points P and Q (I couldn't upload an image(rep !> 10 yet)).
I hope someone here can help shed some light on this for me.
So that we're clear on definitions: A pair of diameters of an ellipse are conjugate if (and only if) the tangents at the endpoints of one diameter are parallel to the other diameter.
Let $P(a \cos\theta, b \sin\theta)$ be a point on an ellipse in standard position (for now). The tangent line at $P$ has slope vector $(-a\sin\theta, b\cos\theta)$; because this can be written $(a\cos(\theta+\pi/2), b\sin(\theta+\pi/2))$, we see that it is also the position vector of a point, say $Q$, on the ellipse. The diameter through $P$ is conjugate to the diameter through $Q$.
Therefore, if we have $P(p_x, p_y)$ and $Q(q_x, q_y)$ as endpoints of conjugate diameters of an ellipse in standard position (with $\angle POQ < \pi$ a counterclockwise angle), we can write:
$$\begin{align} p_x = \phantom{-}a \cos\theta &\qquad p_y = b \sin\theta \\ q_x = -a\sin\theta &\qquad q_y = b\cos\theta \end{align}$$ for some $\theta$, so that $$a^2 = p_x^2 + q_x^2 \qquad\qquad b^2 = p_y^2 + q_y^2 \qquad\qquad (\text{and}\quad p_x q_y - p_y q_x = a b)$$
If the ellipse in question is rotated, things are a little more complicated.
We take $P$ and $Q$ to be the images of $(a\cos\theta, b\sin\theta)$ and $(-a\sin\theta, b\cos\theta)$ under rotation by angle, say, $\phi$. Using an appropriate rotation matrix, we have
$$\begin{align} p_x = \phantom{-}a \cos\theta \cos\phi - b \sin\theta \sin\phi &\qquad p_y = \phantom{-}a \cos\theta \sin\phi + b \sin\theta \cos\phi \\ q_x = -a \sin\theta \cos\phi - b \cos\theta \sin\phi &\qquad q_y = -a \sin\theta \sin\phi + b \cos\theta \cos\phi \end{align}$$
These provide relations
$$\begin{align} p_x^2 + p_y^2 + q_x^2 + q_y^2 &= a^2 + b^2 &=: r \\ p_x q_y - p_y q_x &= a b &=: s \end{align}$$ (The latter actually re-captures a result, cited by Isaac Newton, that all "bounding parallelograms" of an ellipse have the same area.)
Thus, $$\begin{align} a + b &= \sqrt{a^2 + b^2 + 2 a b} = \sqrt{r + 2 s} \\ |a - b| &= \sqrt{a^2 + b^2 - 2 a b} = \sqrt{r - 2 s} \end{align}$$ so that $$\{a,b\} = \frac{1}{2}\left(\sqrt{r + 2 s} \pm \sqrt{r - 2 s}\right)$$
Taking $a \ge b$, we eliminate the ambiguity: $$ a = \frac{1}{2}\left(\sqrt{r+2s} + \sqrt{r-2s}\right) \qquad\qquad b = \frac{1}{2}\left(\sqrt{r+2s} - \sqrt{r-2s}\right)$$
We can (and should) solve for $\theta$ and $\phi$. Start by observing ... $$\begin{align} p_x^2 + p_y^2 = a^2\cos^2\theta+b^2\sin^2\theta &\qquad q_x^2 + q_y^2 = a^2\sin^2\theta+b^2\cos^2\theta \\ p_x^2 + q_x^2 = a^2\cos^2\phi + b^2\sin^2\phi &\qquad p_y^2 + q_y^2 = a^2\sin^2\phi + b^2\cos^2\phi \end{align}$$ so that $$\begin{align} \left(p_x^2+p_y^2\right)-\left(q_x^2+q_y^2\right) &= \left(a^2-b^2 \right)\left(\cos^2\theta-\sin^2\theta\right) = \sqrt{r^2 - 4 s^2}\;\cos 2\theta\\[6pt] \left(p_x^2+q_x^2\right)-\left(p_y^2+q_y^2\right) &= \left(a^2-b^2 \right)\left(\cos^2\phi-\sin^2\phi\right) = \sqrt{r^2-4s^2}\;\cos 2\phi \end{align}$$ whence $$\cos 2\theta = \frac{\left(p_x^2+p_y^2\right)-\left(q_x^2+q_y^2\right)}{\sqrt{r^2-4s^2}} \qquad \cos 2\phi = \frac{\left(p_x^2+q_x^2\right)-\left(p_y^2+q_y^2\right)}{\sqrt{r^2-4s^2}}$$
(Parameter $\theta$ itself isn't important for your purposes, but it's worth noting how its expression in terms of $P$ and $Q$ matches that of $\phi$.)