Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shortest Distance to Ellipse from Point

Status
Not open for further replies.

androsnich

Civil/Environmental
May 7, 2003
12
Shortest Distance to Ellipse from Point,
Or: What is the Line Perpendicular to the Ellipse?


What is a good method to determine the shortest distance from a point to an Ellipse? This is similar to finding the line through a given point that is perpendicular to an ellipse.

To make it simple, I have the ellipse centered at the origin, (0,0), and the major axis along x. Also the point is always in quadrant I, and is always outside the ellipse.

Thanks for your help,
Harry
 
Replies continue below

Recommended for you

Well, you know the equation of the ellipse and you know the coordinates of the point. So, you calculate the coordinates of points along the ellipse at whatever intervals you choose (depending on the degree or accuracy desired), then calculate the distance between each point and the known point. Minimize that distance and you're there. A solve block in MathCAD would work, you could se tit up in Excel, or you could draw it in some CAD program and measure the distance using perpendicular snap.

Did that help?
 
I forgot to say I am initially looking for a closed form solution...non-iterative. And I am programming the solution using Fortran (or C). I also have to do this about 1.5 million times or so. (IFR: I like your iterative method because it is very straight forward, but may be time consuming.)

Harry
 
Since you have taken all the complexity out of it isn't this just the intersection of the line connecting the point with the origin, with the ellipse? If so it is a simple quadratic to find the point of intersection, and the rest is obvious.

If I've missed something then I suspect you need to look at the gradient of the two and make sure that one is (-1/the other gradient), but I'm pretty sure my first para covers your problem.

Cheers

Greg Locock
 
Having slept on it I think the first para is wrong, and probably applies only to circles, the second is on the right track but may not be helpful.

Why not set up an equation for the intersection between a circle, centre x1,y1, and your ellipse. Differentiate this to find the maxima and minima to find the minimum real value of r.

ax^2+by^2=1 (you did align the ellipse to the axes)

(x-x1)^2+(y-y1)^2=r^2

a,b,x1 and y1 are all known

Looks gnarly but doable. My electronic brain is elsewhere, sadly.


Cheers

Greg Locock
 
If I'm not in error I found that this problem requires the solution of a quartic equation, and this is the highest order for which a closed form solution exists.
However the algebraic manipulations required are really too cumbersome.
If you want to give it a try, here's my starting point.
The equation of the normal to the point (x[sub]1[/sub],y[sub]1[/sub]) on the ellipse is:
(x-x[sub]1[/sub])/b[sup]2[/sup]x[sub]1[/sub]=(y-y[sub]1[/sub])/a[sup]2[/sup]y[sub]1[/sub]
Your point (x[sub]0[/sub],y[sub]0[/sub]) must lie on this line, then substituting it to (x,y) and solving for the unknown point (x[sub]1[/sub],y[sub]1[/sub]) you should find:
(a[sup]2[/sup]-b[sup]2[/sup])x[sub]1[/sub]+b[sup]2[/sup]y[sub]0[/sub]x[sub]1[/sub]/y[sub]1[/sub]=a[sup]2[/sup]x[sub]0[/sub]
Rearranging to use the parametric form of ellipse's equation x[sub]1[/sub]/a=cos&[ignore]theta[/ignore]; and y[sub]1[/sub]/b=sin&[ignore]theta[/ignore]; and using the well known relationships
cos&[ignore]theta[/ignore];=(1-t[sup]2[/sup])/(1+t[sup]2[/sup]) and tan&[ignore]theta[/ignore];=2t/(1-t[sup]2[/sup])
you should obtain something like:
(1-t[sup]2[/sup])2t(1-b[sup]2[/sup]/a[sup]2[/sup])+(1-t[sup]2[/sup])(1+t[sup]2[/sup])2y[sub]0[/sub]b/a[sup]2[/sup]=2t(1+t[sup]2[/sup])x[sub]0[/sub]/a
This is the quartic equation: good luck!

prex

Online tools for structural design
 
Harry,
Does this solution have to be exact or can you work with a tolerance, say some percentage of the major axis ?. If so then it can done without solving a quartic every time or using any iterative methods.
 
kapitan,

As I have been thinking about solving quartics, I have considered the solution does not have to be exact. Some of the accuracy criteria I have thought of are:

1) The accuracy could be expressed as the point-ellipse distance +/- some absolute tollerance.

2) Or the accuracy could be expressed as the point-ellipseline's angle to the ellipse. This angle will be perpendicular at the exact sollution. An angle of +/- 0.5 degrees is ok.

Harry

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor