From: kovarik@mcmail.cis.McMaster.CA (Zdislav V. Kovarik) Newsgroups: sci.math Subject: Re: Ellipse problem Date: 10 Nov 1998 13:01:00 -0500 In article , Virgil Hancher wrote: :In article <3646BB67.F5F6BA5E@ibm.net>, George Weisz :wrote: : :> Hi all.... :> I am looking for the equation defining the :> shortest distance from (0,0) to the perimeter of :> an ellipse :> with center at (cx,cy), having a and b as axes and :> rotated by an arbitrary angle around (cx,cy). :> Any help is appreciated :> George : :You might start by picking a new coordinate system rotated to have :axes parallel to the axes of symmetry of the ellipse. Solve the :problem in rotated coordinate system, then rotate back. If nothing else, :the equation of the ellipse becomes much simpler in the rotated system. : :Hope this helps. Simplify it even more: put the origin into the center of the ellipse, so that the ellipse has equation (x/a)^2 + (y/b)^2 = 1 and the point (the old origin) has coordinates (c,d). Then it becomes tougher: the distance can be obtained by first solving an equation which is essentially of degree 4; its unknown is L, and it says (c/(L-a))^2 + (d/(L-b))^2 - 1 = 0 and then the smallest positive root L will be the distance. There will be a positive root; if L is very large, the left side is negative, while if L is slightly larger than the major semiaxis then the left side is large positive, and it is continuous in between. And there will be no more than 4 roots. If there are other positive roots, they measure the other normals from the given point to the curve. The point (x,y) on the ellipse where the normal intersects it at right angles is then given by x = a*c/(a-L) and y = b*d/(b-L). How did I find out? I used the Lagrange Multiplier Method. Cheers, ZVK(Slavek). ============================================================================== From: rusin@vesuvius.math.niu.edu (Dave Rusin) Newsgroups: sci.math Subject: Re: Ellipse problem Date: 10 Nov 1998 20:29:20 GMT In article <3646BB67.F5F6BA5E@ibm.net>, George Weisz wrote: >I am looking for the equation defining the >shortest distance from (0,0) to the perimeter of an ellipse >with center at (cx,cy), having a and b as axes and >rotated by an arbitrary angle around (cx,cy). Probably easiest with Lagrange Multipliers: your ellipse can be written in the form q(x,y) = 0 for some quadratic polynomial q . You need to choose (x,y) to minimize f(x,y) = x^2+y^2, subject to the constraint that q(x,y) = 0. By Lagrange Multipliers (hmm -- must be that time in the semester, eh?) the nearest point will be one of the ones on the ellipse where the gradient of q is parallel to (2x, 2y) (which is the gradient of f), and so by cross-multiplying we obtain the condition x * dq/dy = y * dq/dx, a quadratic equation which, in conjunction with q(x,y)=0, specifies the closest point (x,y) on the ellipse up to finite ambiguity. I am hoping your interest is in computing numerical solutions; for then this approach leads to a quartic equation in one variable x, which is readily solved numerically. Then solve q(x,y)=0 for y and D^2=s^2+y^2 for D, which is what you asked for. Did you instead want a symbolic solution? We have the system of equations x * dq/dy = y * dq/dx \___ These define (x,y) q(x,y) = 0 / D^2 = x^2+y^2 ------------ This defines the distance D dq/dx( cx, cy ) = 0 \_______These define cx and cy dq/dy( cx, cy ) = 0 / and equations which determine the lengths a,b of the semi-axes and their orientation from the Hessian matrix of q, suitably normalized. There are then enough equations to eliminate the coefficients of q (up to a common multiple), leaving us with (generically) a single polynomial equation in D,a,b,cx,cy, and, say, the tangent of the angle through which the ellipse must be rotated until the major axis is horizontal. From this perspective it seems unlikely that we should expect to be able to solve for D explicitly, but possibly one could compute the coefficients of this polynomial determining D as explicit polynomials in the other variables. Just don't expect _me_ to do it! dave