Fitting xy points to an ellipse to obtain center, major and minor axis as well as angle of rotation is not possible in an XY coordinates because for every X, there are duplicate Y value (or even no Y value if there is noise in X).
We must re-parameterize it, for example in a suitable spherical system where the objective function tries to minimize the difference in distance from the center between data an fit.
Here is a simple example (first posted here😞

(As shown here, complex datatypes dramatically simply all the math (scaling, rotation, angle unwrap, etc.)
Note: the general principle can be easily adapted to higher dimensions and I successfully used it to do optimization of points in 3D space many times in the past.