In this Q&A about fitting an ellipse to a set of points, there are multiple answers that generated general equations of the ellipse, like this one by @ubpdqn:
However, the steps to find out the properties of the ellipse (namely, major axis, minor axis, center, and rotation) from its given equation seems pretty complicated. Therefore, my goal is to try finding these properties in a more intuitive way (if possible).
Let's say I start with this general equation of a particular ellipse:
ellipse = -1.43328 - 0.281261 x + 0.00228797 x^2 - 0.832702 y +
0.00138781 x y + 0.00209387 y^2;
ContourPlot[ellipse == 0, {x, -500, 500}, {y, -500, 500}]
A way to find its properties is to start with a simple centered, axis-aligned ellipse with the general formula, where a and b represents the half-lengths of the ellipse' axes: $$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$
The second step is to subtract the expression by 1 to convert our equation to the form expr=1 to expr=0, which is the way our general formula is written (see top of question).
Then, this ellipse is rotated a certain degree, which means that each x and y in the equation is corrected with the rotation angle alpha [Ref], like so: $$x\to x \cos (\alpha )-y \sin (\alpha ),y\to x \sin (\alpha )+y \cos (\alpha )$$
This tilted ellipse is then brought off-center to make our original ellipse, which will transform x and y like so: $$x\to x-h,y\to y-k$$ where (h,k) represents the coordinate of the ellipse' center.
This is the final formula as done via MMA:
ellipseTransform =
Collect[#, {x,
y}] &@(x^2/a^2 + y^2/b^2 -
1 /. {x -> x Cos[\[Alpha]] - y Sin[\[Alpha]],
y -> x Sin[\[Alpha]] + y Cos[\[Alpha]]} /. {x -> x - h,
y -> y - k})
, which gives
A plot of this formula confirms that this is indeed an ellipse
ContourPlot[(ellipseTransform /. {a -> 300, b -> 200, h -> 100,
k -> 50, \[Alpha] -> 30 \[Degree]}) == 0, {x, -500,
500}, {y, -500, 500}, Axes -> True]
As you can see the transformed equation of the simple ellipse now resembles the form of our given ellipse, which includes a constant term, an x term, y term, xy term, x^2 term, and y^2 term (6 terms) in total. My goal now is to somehow solve for a, b, h, k and alpha using the fact that these 2 expressions are basically equivalent.
Now this is when I got stuck, as I've tried a few ways to equate these 2 expressions to look for what I want but to no avail:
Another (perhaps related) problem is that there are 5 unknowns (a,b,h,k,apha) but 6 equations i.e. the 6 coefficients in my ellipse equation. I suppose this problem is more a mathematics one than of Mathematica but I'm wondering if there's any way to solve (or at least optimize) an overdefined set of equations.