The MathWorld resource here gives a formula for the counter-clockwise angle $\phi$ between the x-axis and the major-axis of an ellipse $a x^2 +2bxy + cy^2 + 2dx + 2fy + g = 0$ as
But what do I do when $a=c$? For example the ellipse below is rotated by $\pi/4$ but $a$ and $c$ are equal so are undefined in the above equation. Does this formula need a slight tweak (with a "$\leq$" symbol)?
Best Answer
Consider the answer as
$$ \phi = \frac{1}{2} {\rm atan}\left(\frac{2 b}{a-c}\right) = \mbox{ 0.5*atan2(2b, a-c) } $$
You will also find that
$$\begin{align} \cos (2 \phi) &= \frac{a-c}{\sqrt{(a-c)^2+4 b^2}} \\ \sin (2 \phi) &= \frac{2 b}{\sqrt{(a-c)^2+4 b^2}} \end{align}$$