Finding ellipse from points and distances, 2d space sim/two body problem

120 Views Asked by At

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.

3

There are 3 best solutions below

6
On BEST ANSWER

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}. $$

enter image description here

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.

enter image description here

1
On

Short answer is you need between 3 and 5 points, depending on how fancy you feel.

I believe the minimum you would need are three points and a focus to determine the ellipse. Intuitively, if your ellipse has one focus at origin and another at $F=(x_0,y_0)$, and $r$ is the diameter of the ellipse (the maximal distance), then the equation of an ellipse would be $|X|+|F-X|=r$. Here $F$ has two unknowns, together with $r$ you have three unknowns, so three sample points provide you three equations with three unknowns. The equations are of course nonlinear, but I believe in this case that would be enough to determine the ellipse.

Also there is a similar thread where it is discussed how to find all ellipses based of focus and two points. In there there it is shown that the other focus $F$ belongs to a parabola, so if you have three points, you would have that an intersection of three parabolas is your other focal point.

In general, any conic is given by equation $ax^2+by^2+cxy+dx+ey+f=0,$ so having 5 distinct sample points would uniquely determine a conic. In this case 5 samples provide five linear equations, so you would have to solve a linear system with 5 equations and 6 unknowns $a,b,c,d,e,f$, and then any solution to a system provides an equation of a conic.

1
On

You usually need only as many points as you have unknowns. By definition a point lies on an ellipse if given two foci the sum of the points' distances to the two foci is a constant. This gives the general equation:

$\sqrt {(x-a_1)^2+(y-b_1)^2}+ \sqrt{(x-a_2)^2+(y-b_2)^2} = D$, having five unknowns. These are the coordinates of the foci $(a_1,b_1), (a_2,b_2)$ and the Distance, $D$. $D$ is twice the length of the semi-major axis.

If you know one of the foci, then you only need 3 points since the coordinates are no longer unknown.