I have the following two matrices which represent two ellipses with different angles of rotation: $$\begin{pmatrix} 0.137956 & 0.00275827 \\ 0.00275827 & 0.0406408\end{pmatrix}$$
$$\begin{pmatrix}0.0698865 & 0.0545128 \\ 0.0545128 & 0.0698865\end{pmatrix}$$
From the matrices, how can I calculate the angle of rotation of each ellipse ?
Thanks, Andrew
If you know how to compute eigenvectors of a matrix, then you can find the rotation angle by computing them for this matrix because the eigenvectors of the matrix of a conic point in the directions of its principal axes.
Alternatively, you can solve for it directly. When an ellipse is axis-aligned, its equation doesn’t have any $xy$ terms. This corresponds to the off-diagonal entries of the matrices being zero. So, you need to find the rotation angle that will make these entries vanish. Rotating an ellipse through an angle $-\theta$ is accomplished with the following matrix multiplication: $$\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix} \begin{bmatrix}a&b\\b&c\end{bmatrix} \begin{bmatrix}\cos\theta&\sin\theta\\-\sin\theta&\cos\theta\end{bmatrix}.\tag{*}$$ Expanding the off-diagonal elements results in the equation $$b\cos2\theta+\frac12(a-c)\sin2\theta = 0$$ from which $$\tan2\theta = {2b\over c-a}.$$ If you’re coding this, I suggest using the two-parameter version of the arctangent function since the denominator could be zero. Note, too, that there’s more than one possible rotation angle, all 90° apart, so you’ll have to decide which of these you mean by the rotation angle. For instance, if you want the angle to the major axis, you’ll need to add the constraint that the upper-left element in the result of the product (*) is less than the lower-right one. In terms of eigenvectors, you want the eigenvector that corresponds to the smaller eigenvalue in absolute value.