Cleaning, same as 1223f5f (forgot some predicates)

This commit is contained in:
Mael Rouxel-Labbé 2017-04-19 14:37:36 +02:00
parent 1223f5f5a0
commit 6c1c2fa27b
2 changed files with 138 additions and 145 deletions

View File

@ -649,52 +649,51 @@ compare_power_distanceC2(const FT& px, const FT& py, const FT& pwt,
template <class FT> template <class FT>
Oriented_side Oriented_side
power_side_of_oriented_power_circleC2( const FT &px, const FT &py, const FT &pwt, power_side_of_oriented_power_circleC2(const FT &px, const FT &py, const FT &pwt,
const FT &qx, const FT &qy, const FT &qwt, const FT &qx, const FT &qy, const FT &qwt,
const FT &rx, const FT &ry, const FT &rwt, const FT &rx, const FT &ry, const FT &rwt,
const FT &tx, const FT &ty, const FT &twt) const FT &tx, const FT &ty, const FT &twt)
{ {
// Note: maybe this can be further optimized like the usual in_circle() ? // Note: maybe this can be further optimized like the usual in_circle() ?
// We translate the 4 points so that T becomes the origin. // We translate the 4 points so that T becomes the origin.
FT dpx = px - tx; FT dpx = px - tx;
FT dpy = py - ty; FT dpy = py - ty;
FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt; FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt;
FT dqx = qx - tx; FT dqx = qx - tx;
FT dqy = qy - ty; FT dqy = qy - ty;
FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt; FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt;
FT drx = rx - tx; FT drx = rx - tx;
FT dry = ry - ty; FT dry = ry - ty;
FT drz = CGAL_NTS square(drx) + CGAL_NTS square(dry) - rwt + twt; FT drz = CGAL_NTS square(drx) + CGAL_NTS square(dry) - rwt + twt;
return sign_of_determinant(dpx, dpy, dpz, return sign_of_determinant(dpx, dpy, dpz,
dqx, dqy, dqz, dqx, dqy, dqz,
drx, dry, drz); drx, dry, drz);
} }
template <class FT> template <class FT>
Oriented_side Oriented_side
power_side_of_oriented_power_circleC2( const FT &px, const FT &py, const FT &pwt, power_side_of_oriented_power_circleC2(const FT &px, const FT &py, const FT &pwt,
const FT &qx, const FT &qy, const FT &qwt, const FT &qx, const FT &qy, const FT &qwt,
const FT &tx, const FT &ty, const FT &twt) const FT &tx, const FT &ty, const FT &twt)
{ {
// Same translation as above. // Same translation as above.
FT dpx = px - tx; FT dpx = px - tx;
FT dpy = py - ty; FT dpy = py - ty;
FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt; FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt;
FT dqx = qx - tx; FT dqx = qx - tx;
FT dqy = qy - ty; FT dqy = qy - ty;
FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt; FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt;
// We do an orthogonal projection on the (x) axis, if possible. // We do an orthogonal projection on the (x) axis, if possible.
Comparison_result cmpx = CGAL_NTS compare(px, qx); Comparison_result cmpx = CGAL_NTS compare(px, qx);
if (cmpx != EQUAL) if (cmpx != EQUAL)
return cmpx * sign_of_determinant(dpx, dpz, dqx, dqz); return cmpx * sign_of_determinant(dpx, dpz, dqx, dqz);
// If not possible, then on the (y) axis. // If not possible, then on the (y) axis.
Comparison_result cmpy = CGAL_NTS compare(py, qy); Comparison_result cmpy = CGAL_NTS compare(py, qy);
return cmpy * sign_of_determinant(dpy, dpz, dqy, dqz); return cmpy * sign_of_determinant(dpy, dpz, dqy, dqz);
} }
} //namespace CGAL } //namespace CGAL

View File

@ -561,98 +561,99 @@ has_smaller_signed_dist_to_planeC3(
template <class FT> template <class FT>
CGAL_KERNEL_MEDIUM_INLINE CGAL_KERNEL_MEDIUM_INLINE
typename Same_uncertainty_nt<Oriented_side, FT>::type typename Same_uncertainty_nt<Oriented_side, FT>::type
power_side_of_oriented_power_sphereC3( const FT &px, const FT &py, const FT &pz, const FT &pwt, power_side_of_oriented_power_sphereC3(
const FT &qx, const FT &qy, const FT &qz, const FT &qwt, const FT &px, const FT &py, const FT &pz, const FT &pwt,
const FT &rx, const FT &ry, const FT &rz, const FT &rwt, const FT &qx, const FT &qy, const FT &qz, const FT &qwt,
const FT &sx, const FT &sy, const FT &sz, const FT &swt, const FT &rx, const FT &ry, const FT &rz, const FT &rwt,
const FT &tx, const FT &ty, const FT &tz, const FT &twt) const FT &sx, const FT &sy, const FT &sz, const FT &swt,
const FT &tx, const FT &ty, const FT &tz, const FT &twt)
{ {
// We translate the points so that T becomes the origin. // We translate the points so that T becomes the origin.
FT dpx = px - tx; FT dpx = px - tx;
FT dpy = py - ty; FT dpy = py - ty;
FT dpz = pz - tz; FT dpz = pz - tz;
FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) +
CGAL_NTS square(dpz) + (twt - pwt); CGAL_NTS square(dpz) + (twt - pwt);
FT dqx = qx - tx; FT dqx = qx - tx;
FT dqy = qy - ty; FT dqy = qy - ty;
FT dqz = qz - tz; FT dqz = qz - tz;
FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) +
CGAL_NTS square(dqz) + (twt - qwt); CGAL_NTS square(dqz) + (twt - qwt);
FT drx = rx - tx; FT drx = rx - tx;
FT dry = ry - ty; FT dry = ry - ty;
FT drz = rz - tz; FT drz = rz - tz;
FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) +
CGAL_NTS square(drz) + (twt - rwt); CGAL_NTS square(drz) + (twt - rwt);
FT dsx = sx - tx; FT dsx = sx - tx;
FT dsy = sy - ty; FT dsy = sy - ty;
FT dsz = sz - tz; FT dsz = sz - tz;
FT dst = CGAL_NTS square(dsx) + CGAL_NTS square(dsy) + FT dst = CGAL_NTS square(dsx) + CGAL_NTS square(dsy) +
CGAL_NTS square(dsz) + (twt - swt); CGAL_NTS square(dsz) + (twt - swt);
return - sign_of_determinant(dpx, dpy, dpz, dpt, return - sign_of_determinant(dpx, dpy, dpz, dpt,
dqx, dqy, dqz, dqt, dqx, dqy, dqz, dqt,
drx, dry, drz, drt, drx, dry, drz, drt,
dsx, dsy, dsz, dst); dsx, dsy, dsz, dst);
} }
template <class FT> template <class FT>
CGAL_KERNEL_MEDIUM_INLINE CGAL_KERNEL_MEDIUM_INLINE
typename Same_uncertainty_nt<Oriented_side, FT>::type typename Same_uncertainty_nt<Oriented_side, FT>::type
power_side_of_oriented_power_sphereC3(const FT &px, const FT &py, const FT &pz, const FT &pwt, power_side_of_oriented_power_sphereC3(
const FT &qx, const FT &qy, const FT &qz, const FT &qwt, const FT &px, const FT &py, const FT &pz, const FT &pwt,
const FT &rx, const FT &ry, const FT &rz, const FT &rwt, const FT &qx, const FT &qy, const FT &qz, const FT &qwt,
const FT &tx, const FT &ty, const FT &tz, const FT &twt) const FT &rx, const FT &ry, const FT &rz, const FT &rwt,
const FT &tx, const FT &ty, const FT &tz, const FT &twt)
{ {
// Same translation as above. // Same translation as above.
FT dpx = px - tx; FT dpx = px - tx;
FT dpy = py - ty; FT dpy = py - ty;
FT dpz = pz - tz; FT dpz = pz - tz;
FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) +
CGAL_NTS square(dpz) + (twt - pwt); CGAL_NTS square(dpz) + (twt - pwt);
FT dqx = qx - tx; FT dqx = qx - tx;
FT dqy = qy - ty; FT dqy = qy - ty;
FT dqz = qz - tz; FT dqz = qz - tz;
FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) +
CGAL_NTS square(dqz) + (twt - qwt); CGAL_NTS square(dqz) + (twt - qwt);
FT drx = rx - tx; FT drx = rx - tx;
FT dry = ry - ty; FT dry = ry - ty;
FT drz = rz - tz; FT drz = rz - tz;
FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) +
CGAL_NTS square(drz) + (twt - rwt); CGAL_NTS square(drz) + (twt - rwt);
Sign cmp; Sign cmp;
// Projection on the (xy) plane. // Projection on the (xy) plane.
cmp = sign_of_determinant(dpx, dpy, dpt, cmp = sign_of_determinant(dpx, dpy, dpt,
dqx, dqy, dqt, dqx, dqy, dqt,
drx, dry, drt); drx, dry, drt);
if (cmp != ZERO) if (cmp != ZERO)
return cmp * sign_of_determinant(px-rx, py-ry, return cmp * sign_of_determinant(px-rx, py-ry,
qx-rx, qy-ry); qx-rx, qy-ry);
// Projection on the (xz) plane. // Projection on the (xz) plane.
cmp = sign_of_determinant(dpx, dpz, dpt, cmp = sign_of_determinant(dpx, dpz, dpt,
dqx, dqz, dqt, dqx, dqz, dqt,
drx, drz, drt); drx, drz, drt);
if (cmp != ZERO) if (cmp != ZERO)
return cmp * sign_of_determinant(px-rx, pz-rz, return cmp * sign_of_determinant(px-rx, pz-rz,
qx-rx, qz-rz); qx-rx, qz-rz);
// Projection on the (yz) plane. // Projection on the (yz) plane.
cmp = sign_of_determinant(dpy, dpz, dpt, cmp = sign_of_determinant(dpy, dpz, dpt,
dqy, dqz, dqt, dqy, dqz, dqt,
dry, drz, drt); dry, drz, drt);
return cmp * sign_of_determinant(py-ry, pz-rz, return cmp * sign_of_determinant(py-ry, pz-rz,
qy-ry, qz-rz); qy-ry, qz-rz);
} }
template <class FT> template <class FT>
CGAL_KERNEL_MEDIUM_INLINE CGAL_KERNEL_MEDIUM_INLINE
typename Same_uncertainty_nt<Oriented_side, FT>::type typename Same_uncertainty_nt<Oriented_side, FT>::type
power_side_of_oriented_power_sphereC3(const FT &px, const FT &py, const FT &pz, const FT &pwt, power_side_of_oriented_power_sphereC3(
const FT &qx, const FT &qy, const FT &qz, const FT &qwt, const FT &px, const FT &py, const FT &pz, const FT &pwt,
const FT &tx, const FT &ty, const FT &tz, const FT &twt) const FT &qx, const FT &qy, const FT &qz, const FT &qwt,
const FT &tx, const FT &ty, const FT &tz, const FT &twt)
{ {
// Same translation as above. // Same translation as above.
FT dpx = px - tx; FT dpx = px - tx;
@ -687,28 +688,25 @@ CGAL_KERNEL_MEDIUM_INLINE
typename Same_uncertainty_nt<Oriented_side, FT>::type typename Same_uncertainty_nt<Oriented_side, FT>::type
power_side_of_oriented_power_sphereC3(const FT &pwt, const FT &qwt) power_side_of_oriented_power_sphereC3(const FT &pwt, const FT &qwt)
{ {
return CGAL_NTS compare(qwt, pwt); return CGAL_NTS compare(qwt, pwt);
} }
template < class FT > template < class FT >
Comparison_result Comparison_result
compare_power_distanceC3( compare_power_distanceC3(const FT &px, const FT &py, const FT &pz,
const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &qw,
const FT &qx, const FT &qy, const FT &qz, const FT &qw, const FT &rx, const FT &ry, const FT &rz, const FT &rw)
const FT &rx, const FT &ry, const FT &rz, const FT &rw)
{ {
FT dqx = qx - px; FT dqx = qx - px;
FT dqy = qy - py; FT dqy = qy - py;
FT dqz = qz - pz; FT dqz = qz - pz;
FT drx = rx - px; FT drx = rx - px;
FT dry = ry - py; FT dry = ry - py;
FT drz = rz - pz; FT drz = rz - pz;
return CGAL_NTS compare(dqx*dqx + dqy*dqy + dqz*dqz - qw, return CGAL_NTS compare(dqx*dqx + dqy*dqy + dqz*dqz - qw,
drx*drx + dry*dry + drz*drz - rw); drx*drx + dry*dry + drz*drz - rw);
} }
//return the sign of the power test of weighted point (sx,sy,sz,sw) //return the sign of the power test of weighted point (sx,sy,sz,sw)
//with respect to the smallest sphere orthogonal to //with respect to the smallest sphere orthogonal to
//p,q,r //p,q,r
@ -716,12 +714,12 @@ template< class FT >
CGAL_KERNEL_MEDIUM_INLINE CGAL_KERNEL_MEDIUM_INLINE
typename Same_uncertainty_nt<Bounded_side, FT>::type typename Same_uncertainty_nt<Bounded_side, FT>::type
power_side_of_bounded_power_sphereC3( power_side_of_bounded_power_sphereC3(
const FT &px, const FT &py, const FT &pz, const FT &pw, const FT &px, const FT &py, const FT &pz, const FT &pw,
const FT &qx, const FT &qy, const FT &qz, const FT &qw, const FT &qx, const FT &qy, const FT &qz, const FT &qw,
const FT &rx, const FT &ry, const FT &rz, const FT &rw, const FT &rx, const FT &ry, const FT &rz, const FT &rw,
const FT &sx, const FT &sy, const FT &sz, const FT &sw) const FT &sx, const FT &sy, const FT &sz, const FT &sw)
{ {
// Translate p to origin and compute determinants // Translate p to origin and compute determinants
FT qpx = qx-px; FT qpx = qx-px;
FT qpy = qy-py; FT qpy = qy-py;
FT qpz = qz-pz; FT qpz = qz-pz;
@ -738,11 +736,11 @@ power_side_of_bounded_power_sphereC3(
FT rpw = rr - rw + pw ; FT rpw = rr - rw + pw ;
FT den = determinant(qq,qr, FT den = determinant(qq,qr,
qr,rr); qr,rr);
FT detq = determinant(qpw,qr, FT detq = determinant(qpw,qr,
rpw,rr); rpw,rr);
FT detr = determinant(qq,qpw, FT detr = determinant(qq,qpw,
qr,rpw); qr,rpw);
// Smallest smallest orthogonal sphere center // Smallest smallest orthogonal sphere center
// c = detq/2*den q + detr/2*den r (origin at p) // c = detq/2*den q + detr/2*den r (origin at p)
@ -751,26 +749,25 @@ power_side_of_bounded_power_sphereC3(
FT spx = sx-px; FT spx = sx-px;
FT spy = sy-py; FT spy = sy-py;
FT spz = sz-pz; FT spz = sz-pz;
FT ss = CGAL_NTS square(spx) + CGAL_NTS square(spy) + CGAL_NTS square(spz); FT ss = CGAL_NTS square(spx) + CGAL_NTS square(spy) + CGAL_NTS square(spz);
FT sq = spx*qpx + spy*qpy + spz*qpz; FT sq = spx*qpx + spy*qpy + spz*qpz;
FT sr = spx*rpx + spy*rpy + spz*rpz; FT sr = spx*rpx + spy*rpy + spz*rpz;
CGAL_assertion( ! CGAL_NTS is_zero(den) ); CGAL_assertion( ! CGAL_NTS is_zero(den) );
// return - sign of (c- s)^2 - (c^2 - pw) - sw note that den >= 0 - // return - sign of (c- s)^2 - (c^2 - pw) - sw note that den >= 0 -
return enum_cast<Bounded_side>( return enum_cast<Bounded_side>(
- CGAL_NTS sign( den*(ss - sw + pw)- detq*sq - detr*sr)); - CGAL_NTS sign( den*(ss - sw + pw)- detq*sq - detr*sr));
} }
// return the sign of the power test of weighted point (rx,ry,rz,rw) // return the sign of the power test of weighted point (rx,ry,rz,rw)
// with respect to the smallest sphere orthogoanal to // with respect to the smallest sphere orthogoanal to
// p,q // p,q
template< class FT > template< class FT >
typename Same_uncertainty_nt<Bounded_side, FT>::type typename Same_uncertainty_nt<Bounded_side, FT>::type
power_side_of_bounded_power_sphereC3( power_side_of_bounded_power_sphereC3(
const FT &px, const FT &py, const FT &pz, const FT &pw, const FT &px, const FT &py, const FT &pz, const FT &pw,
const FT &qx, const FT &qy, const FT &qz, const FT &qw, const FT &qx, const FT &qy, const FT &qz, const FT &qw,
const FT &rx, const FT &ry, const FT &rz, const FT &rw) const FT &rx, const FT &ry, const FT &rz, const FT &rw)
{ {
FT FT2(2); FT FT2(2);
FT FT4(4); FT FT4(4);
@ -789,9 +786,6 @@ power_side_of_bounded_power_sphereC3(
- CGAL_NTS sign (dr2 - dp2/FT4 + dpr*dpw/dp2 - drw )); - CGAL_NTS sign (dr2 - dp2/FT4 + dpr*dpw/dp2 - drw ));
} }
} // namespace CGAL
} //namespace CGAL
#endif // CGAL_PREDICATES_KERNEL_FTC3_H #endif // CGAL_PREDICATES_KERNEL_FTC3_H