Regardless of its slope, this line is known to have exactly two
intersections with the ellipse. We choose the closest one to the
point, which corresponds to the smallest root of binomial
equation (5) in absolute value.
Since
,
and
, we can deduce
and
. This implies that when the binomial has real roots,
their sum is strictly positive, so the smallest root in absolute value
is also the smallest root in algebric value.
The classical expression for the smallest root is:
![]() |
However, this expression is not numerically accurate when
because in involves computing something similar to
, leading to a numerical cancellation when
is too small. This case occurs when the test point
is very close to the ellipse
. The limit case is for a
test points lying exactly on the ellipse, for which
is a root so
.
The cancellation can be avoided even at the limit case by using the dual expression of the root:
Since we know
, we know this expression is more stable than the
other one in all cases.
The first point
is computed from
and
using equation (4) and the corresponding
value
is computed from equation (2).
If the test point is very close to the ellipse, we have
, for a given threshold ratio
. In fact, in this case any slope would have given the
same point since
. There is no need to perform any
iteration and we can directly return the values
and
.
Luc Maisonobe 2006-02-04