(This is supposed to be a comment on ja72's answer, but it got too long.)
ja72's answer mentions the formula
$\tan\,2\varphi = \frac{c}{a-b}$
I consider it a bit wasteful of effort to evaluate an arctangent and the subsequently pass it as the argument of a trigonometric unction much later; to avoid this, we can use the double angle formula for the tangent and the "Citardauq" formula in tandem to yield the relation
$\tan\,\varphi=\frac{c}{a-b+(\mathrm{sign}\,c)\sqrt{c^2+(a-b)^2}}$
Denoting this expression as $t$, we can then substitute this into the rotation matrix
$\frac1{\sqrt{1+t^2}}\begin{pmatrix}1&-t\\t&1\end{pmatrix}$
ja72's answer already gave the formulae for the axes; remember that $(p\sin\,u,q\cos\,u)$ and $(p\cos\,u,q\sin\,u)$ are the same ellipse traversed differently, so you can subsequently rotate whichever of the two expressions you pick with the rotation matrix I gave earlier.