Get normals from a point to an ellipse

I'm working on a small software to get normals from a point to an ellipse. I have based it on this article: http://www.mathpages.com/home/kmath505/kmath505.htm and my application works. However I have a small problem, using a polynomial equation of the fourth degree I get the X coordinates of normals points then I can get Y coordinates with a simple formula (last formula in the article), but the choice of sign, depending on whether it is a convex or concave point of normalcy. I have understand it but is there a analytic (NOT graphic) method to understand the right sign?

• I'd recommend doing the computation using parametric equations of the ellipse. It still reduces to finding he roots of a fourth degree equation, but there's no sign ambiguity. – bubba Feb 27 '16 at 14:52

Let the equation of the ellipse be $$\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1.$$ If the point $P$ from which you're trying to find normals is on the $x$ axis then both signs of $y$ are correct. Otherwise, at each of the candidate solution points, if the coordinates of the point are $(x_1,y_1)$, the normal line through that point is $$a^2y_1(x−x_1)=b^2x_1(y−y_1).$$ This gives two lines, one for each choice of sign of $y_1$. Exactly one of these lines will pass through $P$; that is the correct normal line.