diff --git a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h index bdd43017926..087d87d40a3 100644 --- a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h +++ b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h @@ -649,52 +649,51 @@ compare_power_distanceC2(const FT& px, const FT& py, const FT& pwt, template Oriented_side -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 &rx, const FT &ry, const FT &rwt, - const FT &tx, const FT &ty, const FT &twt) +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 &rx, const FT &ry, const FT &rwt, + 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. - FT dpx = px - tx; - FT dpy = py - ty; - FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt; - FT dqx = qx - tx; - FT dqy = qy - ty; - FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt; - FT drx = rx - tx; - FT dry = ry - ty; - FT drz = CGAL_NTS square(drx) + CGAL_NTS square(dry) - rwt + twt; + // We translate the 4 points so that T becomes the origin. + FT dpx = px - tx; + FT dpy = py - ty; + FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt; + FT dqx = qx - tx; + FT dqy = qy - ty; + FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt; + FT drx = rx - tx; + FT dry = ry - ty; + FT drz = CGAL_NTS square(drx) + CGAL_NTS square(dry) - rwt + twt; - return sign_of_determinant(dpx, dpy, dpz, - dqx, dqy, dqz, - drx, dry, drz); + return sign_of_determinant(dpx, dpy, dpz, + dqx, dqy, dqz, + drx, dry, drz); } - template Oriented_side -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 &tx, const FT &ty, const FT &twt) +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 &tx, const FT &ty, const FT &twt) { - // Same translation as above. - FT dpx = px - tx; - FT dpy = py - ty; - FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt; - FT dqx = qx - tx; - FT dqy = qy - ty; - FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt; + // Same translation as above. + FT dpx = px - tx; + FT dpy = py - ty; + FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt; + FT dqx = qx - tx; + FT dqy = qy - ty; + FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt; - // We do an orthogonal projection on the (x) axis, if possible. - Comparison_result cmpx = CGAL_NTS compare(px, qx); - if (cmpx != EQUAL) - return cmpx * sign_of_determinant(dpx, dpz, dqx, dqz); + // We do an orthogonal projection on the (x) axis, if possible. + Comparison_result cmpx = CGAL_NTS compare(px, qx); + if (cmpx != EQUAL) + return cmpx * sign_of_determinant(dpx, dpz, dqx, dqz); - // If not possible, then on the (y) axis. - Comparison_result cmpy = CGAL_NTS compare(py, qy); - return cmpy * sign_of_determinant(dpy, dpz, dqy, dqz); + // If not possible, then on the (y) axis. + Comparison_result cmpy = CGAL_NTS compare(py, qy); + return cmpy * sign_of_determinant(dpy, dpz, dqy, dqz); } } //namespace CGAL diff --git a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h index d0358a628ce..f8cccb8dd0f 100644 --- a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h +++ b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h @@ -561,98 +561,99 @@ has_smaller_signed_dist_to_planeC3( template CGAL_KERNEL_MEDIUM_INLINE typename Same_uncertainty_nt::type -power_side_of_oriented_power_sphereC3( const FT &px, const FT &py, const FT &pz, const FT &pwt, - const FT &qx, const FT &qy, const FT &qz, const FT &qwt, - const FT &rx, const FT &ry, const FT &rz, const FT &rwt, - const FT &sx, const FT &sy, const FT &sz, const FT &swt, - const FT &tx, const FT &ty, const FT &tz, const FT &twt) +power_side_of_oriented_power_sphereC3( + const FT &px, const FT &py, const FT &pz, const FT &pwt, + const FT &qx, const FT &qy, const FT &qz, const FT &qwt, + const FT &rx, const FT &ry, const FT &rz, const FT &rwt, + 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. - FT dpx = px - tx; - FT dpy = py - ty; - FT dpz = pz - tz; - FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + - CGAL_NTS square(dpz) + (twt - pwt); - FT dqx = qx - tx; - FT dqy = qy - ty; - FT dqz = qz - tz; - FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + - CGAL_NTS square(dqz) + (twt - qwt); - FT drx = rx - tx; - FT dry = ry - ty; - FT drz = rz - tz; - FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + - CGAL_NTS square(drz) + (twt - rwt); - FT dsx = sx - tx; - FT dsy = sy - ty; - FT dsz = sz - tz; - FT dst = CGAL_NTS square(dsx) + CGAL_NTS square(dsy) + - CGAL_NTS square(dsz) + (twt - swt); + // We translate the points so that T becomes the origin. + FT dpx = px - tx; + FT dpy = py - ty; + FT dpz = pz - tz; + FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + + CGAL_NTS square(dpz) + (twt - pwt); + FT dqx = qx - tx; + FT dqy = qy - ty; + FT dqz = qz - tz; + FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + + CGAL_NTS square(dqz) + (twt - qwt); + FT drx = rx - tx; + FT dry = ry - ty; + FT drz = rz - tz; + FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + + CGAL_NTS square(drz) + (twt - rwt); + FT dsx = sx - tx; + FT dsy = sy - ty; + FT dsz = sz - tz; + FT dst = CGAL_NTS square(dsx) + CGAL_NTS square(dsy) + + CGAL_NTS square(dsz) + (twt - swt); - return - sign_of_determinant(dpx, dpy, dpz, dpt, - dqx, dqy, dqz, dqt, - drx, dry, drz, drt, - dsx, dsy, dsz, dst); + return - sign_of_determinant(dpx, dpy, dpz, dpt, + dqx, dqy, dqz, dqt, + drx, dry, drz, drt, + dsx, dsy, dsz, dst); } - template CGAL_KERNEL_MEDIUM_INLINE typename Same_uncertainty_nt::type -power_side_of_oriented_power_sphereC3(const FT &px, const FT &py, const FT &pz, const FT &pwt, - const FT &qx, const FT &qy, const FT &qz, const FT &qwt, - const FT &rx, const FT &ry, const FT &rz, const FT &rwt, - const FT &tx, const FT &ty, const FT &tz, const FT &twt) +power_side_of_oriented_power_sphereC3( + const FT &px, const FT &py, const FT &pz, const FT &pwt, + const FT &qx, const FT &qy, const FT &qz, const FT &qwt, + 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. - FT dpx = px - tx; - FT dpy = py - ty; - FT dpz = pz - tz; - FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + - CGAL_NTS square(dpz) + (twt - pwt); - FT dqx = qx - tx; - FT dqy = qy - ty; - FT dqz = qz - tz; - FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + - CGAL_NTS square(dqz) + (twt - qwt); - FT drx = rx - tx; - FT dry = ry - ty; - FT drz = rz - tz; - FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + - CGAL_NTS square(drz) + (twt - rwt); - Sign cmp; + // Same translation as above. + FT dpx = px - tx; + FT dpy = py - ty; + FT dpz = pz - tz; + FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + + CGAL_NTS square(dpz) + (twt - pwt); + FT dqx = qx - tx; + FT dqy = qy - ty; + FT dqz = qz - tz; + FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + + CGAL_NTS square(dqz) + (twt - qwt); + FT drx = rx - tx; + FT dry = ry - ty; + FT drz = rz - tz; + FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + + CGAL_NTS square(drz) + (twt - rwt); + Sign cmp; - // Projection on the (xy) plane. - cmp = sign_of_determinant(dpx, dpy, dpt, - dqx, dqy, dqt, - drx, dry, drt); - if (cmp != ZERO) - return cmp * sign_of_determinant(px-rx, py-ry, - qx-rx, qy-ry); + // Projection on the (xy) plane. + cmp = sign_of_determinant(dpx, dpy, dpt, + dqx, dqy, dqt, + drx, dry, drt); + if (cmp != ZERO) + return cmp * sign_of_determinant(px-rx, py-ry, + qx-rx, qy-ry); - // Projection on the (xz) plane. - cmp = sign_of_determinant(dpx, dpz, dpt, - dqx, dqz, dqt, - drx, drz, drt); - if (cmp != ZERO) - return cmp * sign_of_determinant(px-rx, pz-rz, - qx-rx, qz-rz); + // Projection on the (xz) plane. + cmp = sign_of_determinant(dpx, dpz, dpt, + dqx, dqz, dqt, + drx, drz, drt); + if (cmp != ZERO) + return cmp * sign_of_determinant(px-rx, pz-rz, + qx-rx, qz-rz); - // Projection on the (yz) plane. - cmp = sign_of_determinant(dpy, dpz, dpt, - dqy, dqz, dqt, - dry, drz, drt); - return cmp * sign_of_determinant(py-ry, pz-rz, - qy-ry, qz-rz); + // Projection on the (yz) plane. + cmp = sign_of_determinant(dpy, dpz, dpt, + dqy, dqz, dqt, + dry, drz, drt); + return cmp * sign_of_determinant(py-ry, pz-rz, + qy-ry, qz-rz); } - template CGAL_KERNEL_MEDIUM_INLINE typename Same_uncertainty_nt::type -power_side_of_oriented_power_sphereC3(const FT &px, const FT &py, const FT &pz, const FT &pwt, - const FT &qx, const FT &qy, const FT &qz, const FT &qwt, - const FT &tx, const FT &ty, const FT &tz, const FT &twt) +power_side_of_oriented_power_sphereC3( + const FT &px, const FT &py, const FT &pz, const FT &pwt, + 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. FT dpx = px - tx; @@ -687,28 +688,25 @@ CGAL_KERNEL_MEDIUM_INLINE typename Same_uncertainty_nt::type 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 > Comparison_result -compare_power_distanceC3( - const FT &px, const FT &py, const FT &pz, - const FT &qx, const FT &qy, const FT &qz, const FT &qw, - const FT &rx, const FT &ry, const FT &rz, const FT &rw) +compare_power_distanceC3(const FT &px, const FT &py, const FT &pz, + const FT &qx, const FT &qy, const FT &qz, const FT &qw, + const FT &rx, const FT &ry, const FT &rz, const FT &rw) { - FT dqx = qx - px; - FT dqy = qy - py; - FT dqz = qz - pz; - FT drx = rx - px; - FT dry = ry - py; - FT drz = rz - pz; - return CGAL_NTS compare(dqx*dqx + dqy*dqy + dqz*dqz - qw, - drx*drx + dry*dry + drz*drz - rw); + FT dqx = qx - px; + FT dqy = qy - py; + FT dqz = qz - pz; + FT drx = rx - px; + FT dry = ry - py; + FT drz = rz - pz; + return CGAL_NTS compare(dqx*dqx + dqy*dqy + dqz*dqz - qw, + drx*drx + dry*dry + drz*drz - rw); } - //return the sign of the power test of weighted point (sx,sy,sz,sw) //with respect to the smallest sphere orthogonal to //p,q,r @@ -716,12 +714,12 @@ template< class FT > CGAL_KERNEL_MEDIUM_INLINE typename Same_uncertainty_nt::type power_side_of_bounded_power_sphereC3( - 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 &rx, const FT &ry, const FT &rz, const FT &rw, - const FT &sx, const FT &sy, const FT &sz, const FT &sw) + 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 &rx, const FT &ry, const FT &rz, const FT &rw, + 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 qpy = qy-py; FT qpz = qz-pz; @@ -738,11 +736,11 @@ power_side_of_bounded_power_sphereC3( FT rpw = rr - rw + pw ; FT den = determinant(qq,qr, - qr,rr); + qr,rr); FT detq = determinant(qpw,qr, - rpw,rr); + rpw,rr); FT detr = determinant(qq,qpw, - qr,rpw); + qr,rpw); // Smallest smallest orthogonal sphere center // 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 spy = sy-py; 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 sr = spx*rpx + spy*rpy + spz*rpz; CGAL_assertion( ! CGAL_NTS is_zero(den) ); // return - sign of (c- s)^2 - (c^2 - pw) - sw note that den >= 0 - return enum_cast( - - 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) // with respect to the smallest sphere orthogoanal to // p,q template< class FT > typename Same_uncertainty_nt::type power_side_of_bounded_power_sphereC3( - 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 &rx, const FT &ry, const FT &rz, const FT &rw) + 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 &rx, const FT &ry, const FT &rz, const FT &rw) { FT FT2(2); FT FT4(4); @@ -789,9 +786,6 @@ power_side_of_bounded_power_sphereC3( - CGAL_NTS sign (dr2 - dp2/FT4 + dpr*dpw/dp2 - drw )); } - - - -} //namespace CGAL +} // namespace CGAL #endif // CGAL_PREDICATES_KERNEL_FTC3_H