The language-independant form of this implementation follows. In order
to improve readability, some code optimizations have been removed (use
of precomputed values like
,
and
others). The control parameters of the algorithm are the maximal
number of iterations and the two thresholds
and
.
ifLuc Maisonobe 2006-02-04return
![]()
inside![]()
![]()
![]()
![]()
// distance to the ellipse along the current line as the root of a 2nd degree
// polynom closest to zero:![]()
![]()
![]()
![]()
![]()
![]()
ifreturn
![]()
begin loop for at most N iterations
//th degree normalized polynom describing circle/ellipse intersections
//(there is no need to compute e here)
![]()
![]()
![]()
![]()
// reduce the polynom to degree 3 by removing the already known real root
//![]()
![]()
![]()
![]()
// find the other real root
![]()
![]()
![]()
ifthen
// beware that some programming languages do not provide a cubic root function,
// and that the power function does not accept negative arguments
// (bothand
can be negative)
![]()
![]()
else
![]()
![]()
![]()
![]()
ifthen
![]()
![]()
ifthen
![]()
![]()
end if
end if
end if
//-wise midpoint on the ellipse
![]()
![]()
ifreturn
![]()
![]()
![]()
![]()
if![]()
![]()
![]()
end loop
generate a convergence error