Less tests of sign of expressions

Followup to previous commit.

I have managed to transform most of the tests to simple comparison of input
coordinates. That will ease the writing of static filters. Only six
determinant signs have to be exactly determined.
This commit is contained in:
Laurent Rineau 2012-03-21 11:40:29 +00:00
parent 671464db4c
commit c291e92442
1 changed files with 13 additions and 6 deletions

View File

@ -258,13 +258,15 @@ namespace internal {
CGAL_assertion(dzmax >= 0);
// If t1 > tymax/dymax || tymin/dymin > t2, return false.
if( dymax > 0 && dmin > 0 && (dmin*tymax) < (dymax*tmin) ) return false;
if( dymin > 0 && dmax > 0 && (dmax*tymin) > (dymin*tmax) ) return false;
if( py != qy && px != qx) { // dmin > 0, dymax >0, dmax > 0, dymin > 0
if( (dmin*tymax) < (dymax*tmin) ) return false; // TEST TO FILTER
if( (dmax*tymin) > (dymin*tmax) ) return false; // TEST TO FILTER
}
// If tymin/dymin > t1, set t1 = tymin/dymin.
if( (px == qx) || // <=> (dmin == 0)
( (py != qy) && // <=> (dymin > 0)
(dmin*tymin) > (dymin*tmin) ) )
(dmin*tymin) > (dymin*tmin) ) ) // TEST TO FILTER
{
tmin = tymin;
dmin = dymin;
@ -273,7 +275,7 @@ namespace internal {
// If tymax/dymax < t2, set t2 = tymax/dymax.
if( (px == qx) || // <=> (dmax > 0)
( (py != qy) && // <=> dymax > 0
(dmax*tymax) < (dymax*tmax) ) )
(dmax*tymax) < (dymax*tmax) ) ) // TEST TO FILTER
{
tmax = tymax;
dmax = dymax;
@ -285,8 +287,13 @@ namespace internal {
// CGAL_assertion((dmax == 0) == (px == qx && py == qy));
// If t1 > tzmax || tzmin > t2, return false.
if( dmin > 0 && dzmax > 0 && (dmin*tzmax) < (dzmax*tmin) ) return false;
if( dmax > 0 && dzmin > 0 && (dmax*tzmin) > (dzmin*tmax) ) return false;
if( (px != qx ||
py != qy ) &&
(pz != qz) ) // dmin > 0, dmax > 0, dzmax > 0, dzmin > 0
{
if( (dmin*tzmax) < (dzmax*tmin) ) return false; // TEST TO FILTER
if( (dmax*tzmin) > (dzmin*tmax) ) return false; // TEST TO FILTER
}
return true;
}