Build an ellipse given 3 points and the focus

  • Thread starter cptolemy
  • Start date
  • #1
43
1
Hi,

I'm trying to write a C program to build an ellipse given 3 points and the focus equals to (0,0); can someone help me out?

Regards,

CPtolemy
 

Answers and Replies

  • #2
HallsofIvy
Science Advisor
Homework Helper
41,833
956
The first thing you should do, before writing the program, is determine the equation of the ellipse. Let (a,b) be the unknown focus. Then the total distance (squared) from that focus to the point (x,y) to the known focus (x0, y0) is [itex](x- a)^2+ (y- b)^2+ (x-x_0)^2+ (y- y_0)^2[/itex]. Do that for the three given points as (x, y) and set them equal in pairs. That gives two equations for a and b.
 
  • #3
AlephZero
Science Advisor
Homework Helper
6,994
291
The first thing you should do, before writing the program, is determine the equation of the ellipse. Let (a,b) be the unknown focus. Then the total distance (squared) from that focus to the point (x,y) to the known focus (x0, y0) is [itex](x- a)^2+ (y- b)^2+ (x-x_0)^2+ (y- y_0)^2[/itex]. Do that for the three given points as (x, y) and set them equal in pairs. That gives two equations for a and b.
I think the Halls's equations are more horrible than that, because "distance (squared)" should actually be "distance" so you get the sum of two square roots.

However you can solve this by "classical" geometry that translates into square-root-free equations.

Call the known focus F and the unknown one G, and the three points P Q and R.
Then from the properties of an ellipse,
The distances FP + PG = FQ + QG = FR + RG.

So
PG - QG = FQ - FP
Which says that G lies of a hyperbola with foci P and Q and a known eccentricity (fixed by the distances PQ and FQ-FP)
.
Similarly G lies on two other hyperbolas with equations
QG - RG = FR - FQ
and
RG - PG = FP - FR

You can set up the equations of these hyperbolas in the standard quadratic form and solve them for the position of G. It may be easier to use all three equations to take advantage of the symmetry, rather than work with just two of them.
 
Last edited:
  • #4
4,239
1
Somehow it seems thee points on the curve plus one focal point over-specify an ellipse; that is, there usually won't be a solution. Is that right? It seems to take 5 parameters to specify an ellipse, but eight are given.
 
  • #5
AlephZero
Science Advisor
Homework Helper
6,994
291
Somehow it seems thee points on the curve plus one focal point over-specify an ellipse; that is, there usually won't be a solution. Is that right? It seems to take 5 parameters to specify an ellipse, but eight are given.
That seems to be the case. If you write the general homogeneous quadratic equation
ax^2 + 2hxy + bc^2 + 2gx + 2fy + c = 0

You only have 5 independent parameters out of the 6 a,b,c,f,g,h, to determine ANY conic.

For this problem you have 3 unknown parameters, the x,y coordinates of the other focus, and the eccentricity.

On the other hand, you can always draw a circle through 3 points (if you count a straight line as a circle with infinite radius) but 3 points have 6 independent parameters not 5. So counting the number of independent variables is not as simple as it would be if all the equations were linear :confused:

I seem to remember a theorem that you can draw a conic through any set of 5 points. But 5 points is 10 independent parameters, not 5 :confused: :confused: :confused:

(Clearly all the points must be coplanar for any of this to be interesting)
 
  • #6
4,239
1
I share your confusion. Something very interesting is going on. There must be some way to determine the number of necessary and sufficient coordinates for each family of curves.

Here's one idea in my attempt to make sense of things. Take the simplest example, a straight line specified by 2 points or 4 coordinates, but where y=mx+b has only 2 constant parameters.

So instead, consider a straight line in N dimensions, parametric in λ.

x = aλ+p
y = bλ+q
z = cλ+r
...

The line can be described by two points each with N coordinates or 2N constant parameters, so in this case the (constant) parameter count is equal.

This is more than only a line in N space, but a curve with an origin at (p,q,r). (not to be confused with the coordinate origin) I'm curious as to whether this could make the difference in constant parameter count in the more general case. There may also be something interesting with afine transform of the variable λ, φ=αλ+β --or maybe not.
 
Last edited:
  • #7
43
1
Hi,

Thanks to all. Problem solved.... :)

Kind regards,

CPtolemy
 
  • #8
AlephZero
Science Advisor
Homework Helper
6,994
291
Here's one idea in my attempt to make sense of things. Take the simplest example, a straight line specified by 2 points or 4 coordinates, but where y=mx+b has only 2 constant parameters.

So instead, consider a straight line in N dimensions, parametric in λ.

x = aλ+p
y = bλ+q
z = cλ+r
...

The line can be described by two points each with N coordinates or 2N constant parameters, so in this case the (constant) parameter count is equal.

This is more than only a line in N space, but a curve with an origin at (p,q,r). (not to be confused with the coordinate origin) I'm curious as to whether this could make the difference in constant parameter count in the more general case. There may also be something interesting with afine transform of the variable λ, φ=αλ+β --or maybe not.
I think one way to resolve this is to consider the curve as a set of points, not as an "equation". The set of points on straight line (in any number of dimenensions) can be described by 2 points, i.e. the set {P | there exists λ s.t. P = P_1 + λ P_2 }

Then, the fact that in R^n you can reduce this to a set of n-1 equations with apparently fewer independent parameters (e.g. y = mx + c in R^2) is because the definition of the set involves a linear function of λ.

Similarly you can define the set of points on any circle in R^n for any n using two points, which define a vector of length equal to the radius, from the center, normal to the plane of the circle. Proving that that you can draw a circle through any 3 non-collinear points is then an exercise in vector algebra. (I'm not sure if the fact that this definition only works in R^2 if you consider R^2 as a subspace of R^3 is "interesting", or not...)

One would hope there is a sub-branch of math where this stuff has been sorted out already.
 
  • #9
HallsofIvy
Science Advisor
Homework Helper
41,833
956
I think the Halls's equations are more horrible than that, because "distance (squared)" should actually be "distance" so you get the sum of two square roots.
You are right. I started by thinking that the total distances were equal and that therefore the distances squared would be equal but the total distace is, of course, the sum of two square roots and its square would still involve a square root.

However you can solve this by "classical" geometry that translates into square-root-free equations.

Call the known focus F and the unknown one G, and the three points P Q and R.
Then from the properties of an ellipse,
The distances FP + PG = FQ + QG = FR + RG.

So
PG - QG = FQ - FP
Which says that G lies of a hyperbola with foci P and Q and a known eccentricity (fixed by the distances PQ and FQ-FP)
.
Similarly G lies on two other hyperbolas with equations
QG - RG = FR - FQ
and
RG - PG = FP - FR

You can set up the equations of these hyperbolas in the standard quadratic form and solve them for the position of G. It may be easier to use all three equations to take advantage of the symmetry, rather than work with just two of them.
Nice.
 

Related Threads on Build an ellipse given 3 points and the focus

Replies
5
Views
2K
Replies
3
Views
3K
  • Last Post
Replies
4
Views
2K
Replies
2
Views
2K
Replies
27
Views
4K
  • Last Post
Replies
8
Views
721
Replies
1
Views
2K
Replies
3
Views
4K
  • Last Post
Replies
2
Views
796
Top