BWAPI
|
00001 // Copyright (c) 2000 Utrecht University (The Netherlands), 00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), 00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg 00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), 00005 // and Tel-Aviv University (Israel). All rights reserved. 00006 // 00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00008 // modify it under the terms of the GNU Lesser General Public License as 00009 // published by the Free Software Foundation; version 2.1 of the License. 00010 // See the file LICENSE.LGPL distributed with CGAL. 00011 // 00012 // Licensees holding a valid commercial license may use this file in 00013 // accordance with the commercial license agreement provided with the software. 00014 // 00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 // 00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h $ 00019 // $Id: kernel_ftC2.h 44908 2008-08-12 12:43:20Z spion $ 00020 // 00021 // 00022 // Author(s) : Herve Bronnimann (Herve.Bronnimann@sophia.inria.fr) 00023 // Sylvain Pion 00024 00025 #ifndef CGAL_PREDICATES_KERNEL_FTC2_H 00026 #define CGAL_PREDICATES_KERNEL_FTC2_H 00027 00028 #include <CGAL/algorithm.h> 00029 #include <CGAL/number_utils.h> 00030 #include <CGAL/predicates/sign_of_determinant.h> 00031 #include <CGAL/constructions/kernel_ftC2.h> 00032 00033 CGAL_BEGIN_NAMESPACE 00034 00035 template < class FT > 00036 inline 00037 typename Equal_to<FT>::result_type 00038 parallelC2(const FT &l1a, const FT &l1b, 00039 const FT &l2a, const FT &l2b) 00040 { 00041 return sign_of_determinant(l1a, l1b, l2a, l2b) == ZERO; 00042 } 00043 00044 template < class FT > 00045 typename Equal_to<FT>::result_type 00046 parallelC2(const FT &s1sx, const FT &s1sy, 00047 const FT &s1tx, const FT &s1ty, 00048 const FT &s2sx, const FT &s2sy, 00049 const FT &s2tx, const FT &s2ty) 00050 { 00051 return sign_of_determinant(s1tx - s1sx, s1ty - s1sy, 00052 s2tx - s2sx, s2ty - s2sy) == ZERO; 00053 } 00054 00055 template < class FT > 00056 CGAL_KERNEL_MEDIUM_INLINE 00057 typename Equal_to<FT>::result_type 00058 equal_lineC2(const FT &l1a, const FT &l1b, const FT &l1c, 00059 const FT &l2a, const FT &l2b, const FT &l2c) 00060 { 00061 if (sign_of_determinant(l1a, l1b, l2a, l2b) != ZERO) 00062 return false; // Not parallel. 00063 typename Sgn<FT>::result_type s1a = CGAL_NTS sign(l1a); 00064 if (s1a != ZERO) 00065 return s1a == CGAL_NTS sign(l2a) 00066 && sign_of_determinant(l1a, l1c, l2a, l2c) == ZERO; 00067 return CGAL_NTS sign(l1b) == CGAL_NTS sign(l2b) 00068 && sign_of_determinant(l1b, l1c, l2b, l2c) == ZERO; 00069 } 00070 00071 template < class FT > 00072 CGAL_KERNEL_MEDIUM_INLINE 00073 typename Compare<FT>::result_type 00074 compare_xC2(const FT &px, 00075 const FT &la, const FT &lb, const FT &lc, 00076 const FT &ha, const FT &hb, const FT &hc) 00077 { 00078 // The abscissa of the intersection point is num/den. 00079 FT num = determinant( lb, lc, hb, hc); 00080 FT den = determinant( la, lb, ha, hb); 00081 typename Sgn<FT>::result_type s = CGAL_NTS sign(den); 00082 CGAL_kernel_assertion( s != ZERO ); 00083 return s * CGAL_NTS compare(px * den, num); 00084 } 00085 00086 template < class FT > 00087 CGAL_KERNEL_MEDIUM_INLINE 00088 typename Compare<FT>::result_type 00089 compare_xC2(const FT &la, const FT &lb, const FT &lc, 00090 const FT &h1a, const FT &h1b, const FT &h1c, 00091 const FT &h2a, const FT &h2b, const FT &h2c) 00092 { 00093 /* 00094 FT num1 = determinant( lb, lc, h1b, h1c); 00095 FT den1 = determinant( la, lb, h1a, h1b); 00096 FT num2 = determinant( lb, lc, h2b, h2c); 00097 FT den2 = determinant( la, lb, h2a, h2b); 00098 Sign s = Sign (CGAL_NTS sign(den1) * CGAL_NTS sign(den2)); 00099 CGAL_kernel_assertion( s != ZERO ); 00100 return s * sign_of_determinant(num1, num2, den1, den2); 00101 */ 00102 FT num1 = determinant( la, lc, h1a, h1c); 00103 FT num2 = determinant( la, lc, h2a, h2c); 00104 FT num = determinant(h1a,h1c,h2a,h2c)*lb 00105 + determinant(num1,num2,h1b,h2b); 00106 FT den1 = determinant( la, lb, h1a, h1b); 00107 FT den2 = determinant( la, lb, h2a, h2b); 00108 return CGAL_NTS sign(lb) * 00109 CGAL_NTS sign(num) * 00110 CGAL_NTS sign(den1) * 00111 CGAL_NTS sign(den2); 00112 } 00113 00114 template < class FT > 00115 CGAL_KERNEL_MEDIUM_INLINE 00116 typename Compare<FT>::result_type 00117 compare_xC2(const FT &l1a, const FT &l1b, const FT &l1c, 00118 const FT &h1a, const FT &h1b, const FT &h1c, 00119 const FT &l2a, const FT &l2b, const FT &l2c, 00120 const FT &h2a, const FT &h2b, const FT &h2c) 00121 { 00122 FT num1 = determinant( l1b, l1c, h1b, h1c); 00123 FT den1 = determinant( l1a, l1b, h1a, h1b); 00124 FT num2 = determinant( l2b, l2c, h2b, h2c); 00125 FT den2 = determinant( l2a, l2b, h2a, h2b); 00126 typename Sgn<FT>::result_type s = CGAL_NTS sign(den1) * CGAL_NTS sign(den2); 00127 CGAL_kernel_assertion( s != ZERO ); 00128 return s * sign_of_determinant(num1, num2, den1, den2); 00129 } 00130 00131 template < class FT > 00132 CGAL_KERNEL_MEDIUM_INLINE 00133 typename Compare<FT>::result_type 00134 compare_y_at_xC2(const FT &px, const FT &py, 00135 const FT &la, const FT &lb, const FT &lc) 00136 { 00137 typename Sgn<FT>::result_type s = CGAL_NTS sign(lb); 00138 CGAL_kernel_assertion( s != ZERO ); 00139 return s * CGAL_NTS sign(la*px + lb*py + lc); 00140 } 00141 00142 template < class FT > 00143 CGAL_KERNEL_MEDIUM_INLINE 00144 typename Compare<FT>::result_type 00145 compare_y_at_xC2(const FT &px, 00146 const FT &l1a, const FT &l1b, const FT &l1c, 00147 const FT &l2a, const FT &l2b, const FT &l2c) 00148 { 00149 typename Sgn<FT>::result_type s = CGAL_NTS sign(l1b) * CGAL_NTS sign(l2b); 00150 CGAL_kernel_assertion( s != ZERO ); 00151 return s * sign_of_determinant<FT>(l2a*px+l2c, l2b, 00152 l1a*px+l1c, l1b); 00153 } 00154 00155 template < class FT > 00156 CGAL_KERNEL_LARGE_INLINE 00157 typename Compare<FT>::result_type 00158 compare_y_at_xC2(const FT &l1a, const FT &l1b, const FT &l1c, 00159 const FT &l2a, const FT &l2b, const FT &l2c, 00160 const FT &ha, const FT &hb, const FT &hc) 00161 { 00162 typename Sgn<FT>::result_type s = CGAL_NTS sign(hb) * 00163 sign_of_determinant(l1a, l1b, l2a, l2b); 00164 CGAL_kernel_assertion( s != ZERO ); 00165 return s * sign_of_determinant(l1a, l1b, l1c, 00166 l2a, l2b, l2c, 00167 ha, hb, hc); 00168 } 00169 00170 template < class FT > 00171 CGAL_KERNEL_LARGE_INLINE 00172 typename Compare<FT>::result_type 00173 compare_y_at_xC2(const FT &l1a, const FT &l1b, const FT &l1c, 00174 const FT &l2a, const FT &l2b, const FT &l2c, 00175 const FT &h1a, const FT &h1b, const FT &h1c, 00176 const FT &h2a, const FT &h2b, const FT &h2c) 00177 { 00178 // The abscissa of the intersection point is num/den. 00179 FT num = determinant( l1b, l1c, l2b, l2c); 00180 FT den = determinant( l1a, l1b, l2a, l2b); 00181 typename Sgn<FT>::result_type s = CGAL_NTS sign(h1b) * 00182 CGAL_NTS sign(h2b) * 00183 CGAL_NTS sign(den); 00184 CGAL_kernel_assertion( s != ZERO ); 00185 return s * sign_of_determinant<FT>(h2a*num+h2c*den, h2b, 00186 h1a*num+h1c*den, h1b); 00187 } 00188 00189 template < class FT > 00190 CGAL_KERNEL_LARGE_INLINE 00191 typename Compare<FT>::result_type 00192 compare_y_at_xC2(const FT &px, const FT &py, 00193 const FT &ssx, const FT &ssy, 00194 const FT &stx, const FT &sty) 00195 { 00196 // compares the y-coordinates of p and the vertical projection of p on s. 00197 // Precondition : p is in the x-range of s. 00198 00199 CGAL_kernel_precondition(are_ordered(ssx, px, stx)); 00200 00201 if (ssx < stx) 00202 return orientationC2(px, py, ssx, ssy, stx, sty); 00203 else if (ssx > stx) 00204 return orientationC2(px, py, stx, sty, ssx, ssy); 00205 else { 00206 if (py < (CGAL::min)(sty, ssy)) 00207 return SMALLER; 00208 if (py > (CGAL::max)(sty, ssy)) 00209 return LARGER; 00210 return EQUAL; 00211 } 00212 } 00213 00214 template < class FT > 00215 CGAL_KERNEL_LARGE_INLINE 00216 typename Compare<FT>::result_type 00217 compare_y_at_x_segment_C2(const FT &px, 00218 const FT &s1sx, const FT &s1sy, 00219 const FT &s1tx, const FT &s1ty, 00220 const FT &s2sx, const FT &s2sy, 00221 const FT &s2tx, const FT &s2ty) 00222 { 00223 // compares the y-coordinates of the vertical projections of p on s1 and s2 00224 // Precondition : p is in the x-range of s1 and s2. 00225 // - if one or two segments are vertical : 00226 // - if the segments intersect, return EQUAL 00227 // - if not, return the obvious SMALLER/LARGER. 00228 00229 CGAL_kernel_precondition(are_ordered(s1sx, px, s1tx)); 00230 CGAL_kernel_precondition(are_ordered(s2sx, px, s2tx)); 00231 00232 if (s1sx != s1tx && s2sx != s2tx) { 00233 FT s1stx = s1sx-s1tx; 00234 FT s2stx = s2sx-s2tx; 00235 00236 return CGAL_NTS compare(s1sx, s1tx) * 00237 CGAL_NTS compare(s2sx, s2tx) * 00238 CGAL_NTS compare(-(s1sx-px)*(s1sy-s1ty)*s2stx, 00239 (s2sy-s1sy)*s2stx*s1stx 00240 -(s2sx-px)*(s2sy-s2ty)*s1stx ); 00241 } 00242 else { 00243 if (s1sx == s1tx) { // s1 is vertical 00244 typename Compare<FT>::result_type c1, c2; 00245 c1 = compare_y_at_xC2(px, s1sy, s2sx, s2sy, s2tx, s2ty); 00246 c2 = compare_y_at_xC2(px, s1ty, s2sx, s2sy, s2tx, s2ty); 00247 if (c1 == c2) 00248 return c1; 00249 return EQUAL; 00250 } 00251 // s2 is vertical 00252 typename Compare<FT>::result_type c3, c4; 00253 c3 = compare_y_at_xC2(px, s2sy, s1sx, s1sy, s1tx, s1ty); 00254 c4 = compare_y_at_xC2(px, s2ty, s1sx, s1sy, s1tx, s1ty); 00255 if (c3 == c4) 00256 return -c3; 00257 return EQUAL; 00258 } 00259 } 00260 00261 template < class FT > 00262 CGAL_KERNEL_MEDIUM_INLINE 00263 typename Equal_to<FT>::result_type 00264 equal_directionC2(const FT &dx1, const FT &dy1, 00265 const FT &dx2, const FT &dy2) 00266 { 00267 return CGAL_NTS sign(dx1) == CGAL_NTS sign(dx2) 00268 && CGAL_NTS sign(dy1) == CGAL_NTS sign(dy2) 00269 && sign_of_determinant(dx1, dy1, dx2, dy2) == ZERO; 00270 } 00271 00272 template < class FT > 00273 CGAL_KERNEL_MEDIUM_INLINE 00274 typename Compare<FT>::result_type 00275 compare_angle_with_x_axisC2(const FT &dx1, const FT &dy1, 00276 const FT &dx2, const FT &dy2) 00277 { 00278 // angles are in [-pi,pi], and the angle between Ox and d1 is compared 00279 // with the angle between Ox and d2 00280 int quadrant_1 = (dx1 >= 0) ? (dy1 >= 0 ? 1 : 4) 00281 : (dy1 >= 0 ? 2 : 3); 00282 int quadrant_2 = (dx2 >= 0) ? (dy2 >= 0 ? 1 : 4) 00283 : (dy2 >= 0 ? 2 : 3); 00284 // We can't use CGAL_NTS compare(quadrant_1,quadrant_2) because in case 00285 // of tie, we need additional computation 00286 if (quadrant_1 > quadrant_2) 00287 return LARGER; 00288 else if (quadrant_1 < quadrant_2) 00289 return SMALLER; 00290 return -sign_of_determinant(dx1,dy1,dx2,dy2); 00291 } 00292 00293 template < class FT > 00294 CGAL_KERNEL_MEDIUM_INLINE 00295 typename Compare<FT>::result_type 00296 compare_slopesC2(const FT &l1a, const FT &l1b, const FT &l2a, const FT &l2b) 00297 { 00298 typedef typename Compare<FT>::result_type result_type; 00299 00300 if (CGAL_NTS is_zero(l1a)) // l1 is horizontal 00301 return CGAL_NTS is_zero(l2b) ? result_type(SMALLER) 00302 : CGAL_NTS sign(l2a) * CGAL_NTS sign(l2b); 00303 if (CGAL_NTS is_zero(l2a)) // l2 is horizontal 00304 return CGAL_NTS is_zero(l1b) ? result_type(LARGER) 00305 : - CGAL_NTS sign(l1a) * CGAL_NTS sign(l1b); 00306 if (CGAL_NTS is_zero(l1b)) return CGAL_NTS is_zero(l2b) ? EQUAL : LARGER; 00307 if (CGAL_NTS is_zero(l2b)) return SMALLER; 00308 result_type l1_sign = - CGAL_NTS sign(l1a) * CGAL_NTS sign(l1b); 00309 result_type l2_sign = - CGAL_NTS sign(l2a) * CGAL_NTS sign(l2b); 00310 00311 if (l1_sign < l2_sign) return SMALLER; 00312 if (l1_sign > l2_sign) return LARGER; 00313 00314 if (l1_sign > ZERO) 00315 return CGAL_NTS compare ( CGAL_NTS abs(l1a * l2b), 00316 CGAL_NTS abs(l2a * l1b) ); 00317 00318 return CGAL_NTS compare ( CGAL_NTS abs(l2a * l1b), 00319 CGAL_NTS abs(l1a * l2b) ); 00320 } 00321 00322 template < class FT > 00323 CGAL_KERNEL_MEDIUM_INLINE 00324 typename Compare<FT>::result_type 00325 compare_slopesC2(const FT &s1_src_x, const FT &s1_src_y, const FT &s1_tgt_x, 00326 const FT &s1_tgt_y, const FT &s2_src_x, const FT &s2_src_y, 00327 const FT &s2_tgt_x, const FT &s2_tgt_y) 00328 { 00329 typedef typename Compare<FT>::result_type Cmp; 00330 typedef typename Sgn<FT>::result_type Sg; 00331 Cmp cmp_y1 = CGAL_NTS compare(s1_src_y, s1_tgt_y); 00332 if (cmp_y1 == EQUAL) // horizontal 00333 { 00334 Cmp cmp_x2 = CGAL_NTS compare(s2_src_x, s2_tgt_x); 00335 00336 if (cmp_x2 == EQUAL) return SMALLER; 00337 return - CGAL_NTS sign(s2_src_y - s2_tgt_y) * CGAL_NTS sign(s2_src_x - s2_tgt_x); 00338 } 00339 00340 Cmp cmp_y2 = CGAL_NTS compare(s2_src_y, s2_tgt_y); 00341 if (cmp_y2 == EQUAL) 00342 { 00343 Cmp cmp_x1 = CGAL_NTS compare(s1_src_x, s1_tgt_x); 00344 00345 if (cmp_x1 == EQUAL) return LARGER; 00346 return CGAL_NTS sign(s1_src_y - s1_tgt_y) * CGAL_NTS sign(s1_src_x - s1_tgt_x); 00347 } 00348 00349 Cmp cmp_x1 = CGAL_NTS compare(s1_src_x, s1_tgt_x); 00350 Cmp cmp_x2 = CGAL_NTS compare(s2_src_x, s2_tgt_x); 00351 00352 if (cmp_x1 == EQUAL) return cmp_x2 == EQUAL ? EQUAL : LARGER; 00353 00354 if (cmp_x2 == EQUAL) return SMALLER; 00355 00356 FT s1_xdiff = s1_src_x - s1_tgt_x; 00357 FT s1_ydiff = s1_src_y - s1_tgt_y; 00358 FT s2_xdiff = s2_src_x - s2_tgt_x; 00359 FT s2_ydiff = s2_src_y - s2_tgt_y; 00360 Sg s1_sign = CGAL_NTS sign(s1_ydiff) * CGAL_NTS sign(s1_xdiff); 00361 Sg s2_sign = CGAL_NTS sign(s2_ydiff) * CGAL_NTS sign(s2_xdiff); 00362 00363 if (s1_sign < s2_sign) return SMALLER; 00364 if (s1_sign > s2_sign) return LARGER; 00365 00366 if (s1_sign > ZERO) 00367 return CGAL_NTS compare( CGAL_NTS abs(s1_ydiff * s2_xdiff), 00368 CGAL_NTS abs(s2_ydiff * s1_xdiff)); 00369 00370 return CGAL_NTS compare( CGAL_NTS abs(s2_ydiff * s1_xdiff), 00371 CGAL_NTS abs(s1_ydiff * s2_xdiff)); 00372 } 00373 00374 00375 #if 0 00376 // Unused, undocumented, un-functorized. 00377 template < class FT > 00378 inline 00379 typename Compare<FT>::result_type 00380 compare_deltax_deltayC2(const FT &px, const FT &qx, 00381 const FT &ry, const FT &sy) 00382 { 00383 return CGAL_NTS compare(CGAL_NTS abs(px-qx), CGAL_NTS abs(ry-sy)); 00384 } 00385 #endif 00386 00387 template < class FT > 00388 inline 00389 typename Compare<FT>::result_type 00390 compare_lexicographically_xyC2(const FT &px, const FT &py, 00391 const FT &qx, const FT &qy) 00392 { 00393 typename Compare<FT>::result_type c = CGAL_NTS compare(px,qx); 00394 return (c != EQUAL) ? c : CGAL_NTS compare(py,qy); 00395 } 00396 00397 template < class FT > 00398 inline 00399 typename Same_uncertainty_nt<Orientation, FT>::type 00400 orientationC2(const FT &px, const FT &py, 00401 const FT &qx, const FT &qy, 00402 const FT &rx, const FT &ry) 00403 { 00404 return sign_of_determinant(qx-px, qy-py, rx-px, ry-py); 00405 } 00406 00407 template < class FT > 00408 inline 00409 typename Same_uncertainty_nt<Orientation, FT>::type 00410 orientationC2(const FT &ux, const FT &uy, const FT &vx, const FT &vy) 00411 { 00412 return sign_of_determinant(ux, uy, vx, vy); 00413 } 00414 00415 template < class FT > 00416 inline 00417 typename Same_uncertainty_nt<Angle, FT>::type 00418 angleC2(const FT &px, const FT &py, 00419 const FT &qx, const FT &qy, 00420 const FT &rx, const FT &ry) 00421 { 00422 return enum_cast<Angle>(CGAL_NTS sign((px-qx)*(rx-qx)+(py-qy)*(ry-qy))); 00423 } 00424 00425 template < class FT > 00426 CGAL_KERNEL_MEDIUM_INLINE 00427 typename Equal_to<FT>::result_type 00428 collinear_are_ordered_along_lineC2(const FT &px, const FT &py, 00429 const FT &qx, const FT &qy, 00430 const FT &rx, const FT &ry) 00431 { 00432 if (px < qx) return !(rx < qx); 00433 if (qx < px) return !(qx < rx); 00434 if (py < qy) return !(ry < qy); 00435 if (qy < py) return !(qy < ry); 00436 return true; // p==q 00437 } 00438 00439 template < class FT > 00440 CGAL_KERNEL_MEDIUM_INLINE 00441 typename Equal_to<FT>::result_type 00442 collinear_are_strictly_ordered_along_lineC2(const FT &px, const FT &py, 00443 const FT &qx, const FT &qy, 00444 const FT &rx, const FT &ry) 00445 { 00446 if (px < qx) return (qx < rx); 00447 if (qx < px) return (rx < qx); 00448 if (py < qy) return (qy < ry); 00449 if (qy < py) return (ry < qy); 00450 return false; 00451 } 00452 00453 template < class FT > 00454 CGAL_KERNEL_LARGE_INLINE 00455 typename Same_uncertainty_nt<Oriented_side, FT>::type 00456 side_of_oriented_circleC2(const FT &px, const FT &py, 00457 const FT &qx, const FT &qy, 00458 const FT &rx, const FT &ry, 00459 const FT &tx, const FT &ty) 00460 { 00461 // sign_of_determinant(px, py, px*px + py*py, 1, 00462 // qx, qy, qx*qx + qy*qy, 1, 00463 // rx, ry, rx*rx + ry*ry, 1, 00464 // tx, ty, tx*tx + ty*ty, 1); 00465 // We first translate so that p is the new origin. 00466 FT qpx = qx-px; 00467 FT qpy = qy-py; 00468 FT rpx = rx-px; 00469 FT rpy = ry-py; 00470 FT tpx = tx-px; 00471 FT tpy = ty-py; 00472 // The usual 3x3 formula can be simplified a little bit to a 2x2. 00473 // - sign_of_determinant(qpx, qpy, square(qpx) + square(qpy), 00474 // rpx, rpy, square(rpx) + square(rpy), 00475 // tpx, tpy, square(tpx) + square(tpy))); 00476 return sign_of_determinant<FT>( qpx*tpy - qpy*tpx, tpx*(tx-qx) + tpy*(ty-qy), 00477 qpx*rpy - qpy*rpx, rpx*(rx-qx) + rpy*(ry-qy)); 00478 } 00479 00480 template < class FT > 00481 CGAL_KERNEL_LARGE_INLINE 00482 typename Same_uncertainty_nt<Bounded_side, FT>::type 00483 side_of_bounded_circleC2(const FT &px, const FT &py, 00484 const FT &qx, const FT &qy, 00485 const FT &rx, const FT &ry, 00486 const FT &tx, const FT &ty) 00487 { 00488 return enum_cast<Bounded_side>( side_of_oriented_circleC2(px,py,qx,qy,rx,ry,tx,ty) 00489 * orientationC2(px,py,qx,qy,rx,ry) ); 00490 } 00491 00492 template < class FT > 00493 CGAL_KERNEL_LARGE_INLINE 00494 typename Same_uncertainty_nt<Bounded_side, FT>::type 00495 side_of_bounded_circleC2(const FT &px, const FT &py, 00496 const FT &qx, const FT &qy, 00497 const FT &tx, const FT &ty) 00498 { 00499 // Returns whether T lies inside or outside the circle which diameter is PQ. 00500 return enum_cast<Bounded_side>( 00501 CGAL_NTS compare((tx-px)*(qx-tx), (ty-py)*(ty-qy)) ); 00502 } 00503 00504 template < class FT > 00505 inline 00506 typename Compare<FT>::result_type 00507 cmp_dist_to_pointC2(const FT &px, const FT &py, 00508 const FT &qx, const FT &qy, 00509 const FT &rx, const FT &ry) 00510 { 00511 return CGAL_NTS compare(squared_distanceC2(px,py,qx,qy), 00512 squared_distanceC2(px,py,rx,ry)); 00513 } 00514 00515 template < class FT > 00516 inline 00517 typename Equal_to<FT>::result_type 00518 has_larger_dist_to_pointC2(const FT &px, const FT &py, 00519 const FT &qx, const FT &qy, 00520 const FT &rx, const FT &ry) 00521 { 00522 return cmp_dist_to_pointC2(px,py,qx,qy,rx,ry) == LARGER; 00523 } 00524 00525 template < class FT > 00526 inline 00527 typename Equal_to<FT>::result_type 00528 has_smaller_dist_to_pointC2(const FT &px, const FT &py, 00529 const FT &qx, const FT &qy, 00530 const FT &rx, const FT &ry) 00531 { 00532 return cmp_dist_to_pointC2(px,py,qx,qy,rx,ry) == SMALLER; 00533 } 00534 00535 template < class FT > 00536 inline 00537 typename Compare<FT>::result_type 00538 cmp_signed_dist_to_directionC2(const FT &la, const FT &lb, 00539 const FT &px, const FT &py, 00540 const FT &qx, const FT &qy) 00541 { 00542 return CGAL_NTS compare(scaled_distance_to_directionC2(la,lb,px,py), 00543 scaled_distance_to_directionC2(la,lb,qx,qy)); 00544 } 00545 00546 template < class FT > 00547 inline 00548 typename Equal_to<FT>::result_type 00549 has_larger_signed_dist_to_directionC2(const FT &la, const FT &lb, 00550 const FT &px, const FT &py, 00551 const FT &qx, const FT &qy) 00552 { 00553 return cmp_signed_dist_to_directionC2(la,lb,px,py,qx,qy) == LARGER; 00554 } 00555 00556 template < class FT > 00557 inline 00558 typename Equal_to<FT>::result_type 00559 has_smaller_signed_dist_to_directionC2(const FT &la, const FT &lb, 00560 const FT &px, const FT &py, 00561 const FT &qx, const FT &qy) 00562 { 00563 return cmp_signed_dist_to_directionC2(la,lb,px,py,qx,qy) == SMALLER; 00564 } 00565 00566 template <class FT> 00567 inline 00568 typename Compare<FT>::result_type 00569 cmp_signed_dist_to_lineC2(const FT &px, const FT &py, 00570 const FT &qx, const FT &qy, 00571 const FT &rx, const FT &ry, 00572 const FT &sx, const FT &sy) 00573 { 00574 return CGAL_NTS compare(scaled_distance_to_lineC2(px,py,qx,qy,rx,ry), 00575 scaled_distance_to_lineC2(px,py,qx,qy,sx,sy)); 00576 } 00577 00578 template <class FT> 00579 inline 00580 typename Equal_to<FT>::result_type 00581 has_larger_signed_dist_to_lineC2(const FT &px, const FT &py, 00582 const FT &qx, const FT &qy, 00583 const FT &rx, const FT &ry, 00584 const FT &sx, const FT &sy) 00585 { 00586 return cmp_signed_dist_to_lineC2(px,py,qx,qy,rx,ry,sx,sy) == LARGER; 00587 } 00588 00589 template <class FT> 00590 inline 00591 typename Equal_to<FT>::result_type 00592 has_smaller_signed_dist_to_lineC2(const FT &px, const FT &py, 00593 const FT &qx, const FT &qy, 00594 const FT &rx, const FT &ry, 00595 const FT &sx, const FT &sy) 00596 { 00597 return cmp_signed_dist_to_lineC2(px,py,qx,qy,rx,ry,sx,sy) == SMALLER; 00598 } 00599 00600 template <class FT> 00601 inline 00602 typename Same_uncertainty_nt<Oriented_side, FT>::type 00603 side_of_oriented_lineC2(const FT &a, const FT &b, const FT &c, 00604 const FT &x, const FT &y) 00605 { 00606 return CGAL_NTS sign(a*x+b*y+c); 00607 } 00608 00609 CGAL_END_NAMESPACE 00610 00611 #endif // CGAL_PREDICATES_KERNEL_FTC2_H