Good afternoon, everyone.
Is there any way to find the parameters of an ellipse, knowing random n points of the ellipse? Say, 3, 5, 10, 20 or any other reasonable number that doesn't require a lot of calculations/iterations/processor time? I'm primarily interested in the semi-major axis and eccentricity (a, e) of the ellipse.
What I have now is 2d simulator of space in the context of a two-body problem, so it basically just gravity simulator. Even the one-body problem, if there such one, because gravity in my model only works in one direction, from the orbiting object to the central body, and there is always only one central body in the sphere of influence, which is in one of the two focuses of a ellipse. I have points in the form of (P(x,y), r), where r is the distance to the central body at a particular point, and P(x,y) is the coordinates of the point in the coordinate grid. So, in essence, these points are the result of modeling a process over time. I want to go from a simulation to an more or less analytical solution.
I have found several similar questions and even answers, but some say it is impossible because there are an infinite number of possible ellipses going through these points, others say it is possible and provide matrices and equations that are hard to understand without knowing what they are and whether it applies to the scenario at all. I've also heard of some methods like linear(...) regression or ellipse fitting, but they seem to come from machine learning, and you have to have initial guesses for those values, so I guess that's not what I need. I also found notes that say I have to solve some numerical methods, but again without specifics it is extremely difficult to understand.
I've never studied math or physics in a high-profile sense, so please correct me if I'm wrong about anything. I would be very grateful for a clear and simple answer and a rough direction, if possible, or a rough idea of where I should even go.
I propose you another approach, exploiting the focus-directrix property of the ellipse. Say we have then three points $A$, $B$, $C$ on an ellipse, of which we know the position of focus $F$ (see figure below).
To $F$ a line is associated, called directrix, perpendicular to the major axis of the ellipse and with the following property: if $A'$ is the projection on the directrix of a point $A$ on the ellipse, then $FA=e AA'$, where $e$ is constant ($0<e<1$) called the eccentricity of the ellipse.
We can draw through $B$ a line parallel to the directrix, meeting $AA'$ at $K$ and $CC'$ at $L$. We have then: $$ AB\sin\alpha=AK=AA'-BB'={FA-FB\over e}, \quad BC\sin\gamma=CL=CC'-BB'={FC-FB\over e}, $$ where $\alpha=\angle ABK$ and $\gamma=\angle CBL$ are two unknown angles.
Let's set $$ r_A={BA\over FA-FB},\quad r_C={BC\over FC-FB}; $$ taking into account that $\gamma=\pi-\alpha-\beta$, where $\beta=\angle ABC$ is known, the previous equalities can be rewritten as: $$ \tag{1} {1\over e}=r_A\sin\alpha =r_C\sin(\alpha+\beta). $$ The second equality is an equation for $\alpha$, which can be readily solved: $$ \tan\alpha={r_C\sin\beta\over r_A-r_C\cos\beta}. $$ Once $\alpha$ is known, the eccentricity $e$ can be computed from $(1)$. Moreover, the slopes of the directrix and of line $FF'$ (perpendicular to the directrix) can be found.
We can finally compute $FH$ and $FF'=FH+BB'=FH+{1\over e}FB$. From there we can get the vertices $V$ and $W$: $$ FV={eFF'\over1+e},\quad FW={eFF'\over1-e}. $$
Some final observations. The construction works only if an ellipse through $ABC$ with focus $F$ exists, which is not guaranteed for a generic choice of the points. I uploaded a GeoGebra file with this construction.
The definitions of $r_A$ and $r_C$ seem to lack an absolute value in the denominator, but the changes in the construction when those quantities become negative are automatically taken into account by their signs, hence no absolute value is necessary.
EDIT.
Here's another geometric construction, found in an old book and looking quite simple and robust.
Construct a point $Z$ on line $AB$ such that $AZ:BZ=AF:BF$, that is: $$ Z=B+{FB\over FA-FB}(B-A). $$ And construct a point $W$ on line $AC$ such that $AW:CW=AF:CF$, that is: $$ W=C+{FC\over FA-FC}(C-A). $$ By construction, line $WZ$ is the directrix of the ellipse. Drop the perpendicular $FH$ from the focus to the directrix. Instead of finding on it the vertices as in the previous construction, we can construct as follows the second focus $G$.
Drop from $F$ the perpendicular to $BF$, intersecting the directrix at $K$: line $BK$ is then a tangent to the ellipse. Reflect $F$ about this tangent to $F'$: the intersection of line $BF'$ with $FH$ is the second focus $G$ of the ellipse.