Minimum Distance to an Ellipse
Date: 06/10/99 at 11:18:23 From: Christian Gauthier Subject: Geometry Conic Ellipse What is the minimum distance between a point inside or outside an ellipse and the ellipse, if I know the general equation of the ellipse Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0?
Date: 06/10/99 at 15:26:53 From: Doctor Rob Subject: Re: Geometry Conic Ellipse There may be a general formula for this, but if so, it is so complicated that no one would ever write it out explicitly. I would find the distance in the following way. The point Q(x0,y0) on the ellipse whose distance from the given point P(X,Y) is least at a point such that the tangent to the ellipse at Q is perpendicular to the line PQ. The slope of the tangent at Q can be found by implicitly differentiating the equation of the ellipse and solving for dy/dx, then substituting in x0 and y0. Then the line perpendicular to this tangent has slope -1/(dy/dx), and it passes through Q, so the point-slope form will give you its equation in terms of A, B, C, D, E, F, x0, and y0. Since the point P lies on this line, that gives you an equation that x0 and y0 must satisfy, in addition to the equation of the ellipse. By eliminating y0 from these two equations, you get a quartic equation in x0. This may have zero, two, or four real solutions. Each one will give a corresponding value of y0. Then for these solutions, the distance PQ should be computed, and the smallest of them chosen as the answer. For an ellipse, the largest one will give you the point farthest from P. In theory, you can solve the quartic in terms of radicals, but the result of trying to do that is generally an unmanageably complicated formula. Once you have the quartic, if you cannot factor it into linear and quadratic factors, you might as well solve it numerically. Note that this solution does not depend on the curve being an ellipse, just a quadratic equation in x and y. It will give you the answer for parabolas, hyperbolas, and degenerate conics, too. As an example, take the point P(3,8) and the ellipse x^2 + x*y + y^2 + 2*x + 4*y - 9 = 0. Then 2*x + x*(dy/dx) + y + 2*y*(dy/dx) + 2 + 4*(dy/dx) = 0, dy/dx = -(2*x+y+2)/(x+2*y+4), and the slope of the perpendicular to the tangent line at Q(x0,y0) is m = (x0+2*y0+4)/(2*x0+y0+2), and that line is y - y0 = [(x0+2*y0+4)/(2*x0+y0+2)]*(x-x0). Since P(3,8) is on that line, we get the equation 8 - y0 = [(x0+2*y0+4)/(2*x0+y0+2)]*(3-x0), 4 + 17*x0 + x0^2 = y0^2, and since Q is on the curve, we get the equation x0^2 + x0*y0 + y0^2 + 2*x0 + 4*y0 - 9 = 0. Eliminating y0 from these two equations, we end up with the quartic equation 3*x0^4 + 51*x0^3 + 185*x0^2 - 494*x0 - 39 = 0. This polynomial doesn't factor, so we solve numerically. There are two real roots, x0 = -0.0767858556 and x0 = 1.7998308063, approximately, and the corresponding values of y are y0 = 1.6433309230 and y0 = -6.1511392960, approximately. The first point has distance 7.0621422356 and the second 14.2019417499 from P, so the minimum distance from P to the ellipse is 7.0621422356. Another approach is to use a Lagrange Multiplier. Set f(x,y,z) = (x-X)^2 + (y-Y)^2 + z*(A*x^2+B*x*y+C*y^2+D*x+E*y+F). Then set the partials of f with respect to x, y, and z equal to zero, and solve for x, y, and z. That will give you x = x0 and y = y0. The resulting equations will be the same, because eliminating z from the first two equations will give you the equation of the line PQ we got above, and the last equation will be the equation of the ellipse. - Doctor Rob, The Math Forum http://mathforum.org/dr.math/
Search the Dr. Math Library:
Ask Dr. MathTM
© 1994-2015 The Math Forum