diff --git a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h index e30c68b2022..bc7e134ceef 100644 --- a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h +++ b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h @@ -418,6 +418,65 @@ scaled_distance_to_lineC2( const FT &px, const FT &py, return determinant(px-rx, py-ry, qx-rx, qy-ry); } + +template < class RT > +void +weighted_circumcenter_translateC2(const RT &dqx, const RT &dqy, const RT &dqw, + const RT &drx, const RT &dry, const RT &drw, + RT &dcx, RT &dcy) +{ + // Given 3 points P, Q, R, this function takes as input: + // qx-px, qy-py,qw-pw, rx-px, ry-py, rw-pw. And returns cx-px, cy-py, + // where (cx, cy) are the coordinates of the circumcenter C. + + // What we do is intersect the radical axis + RT r2 = CGAL_NTS square(drx) + CGAL_NTS square(dry) - drw; + RT q2 = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - dqw; + + RT den = RT(2) * determinant(dqx, dqy, drx, dry); + + // The 3 points aren't collinear. + // Hopefully, this is already checked at the upper level. + CGAL_assertion ( den != RT(0) ); + + // One possible optimization here is to precompute 1/den, to avoid one + // division. However, we loose precision, and it's maybe not worth it (?). + dcx = determinant (dry, dqy, r2, q2) / den; + dcy = - determinant (drx, dqx, r2, q2) / den; +} + +//template < class RT > +template < class RT, class We> +void +weighted_circumcenterC2( const RT &px, const RT &py, const We &pw, + const RT &qx, const RT &qy, const We &qw, + const RT &rx, const RT &ry, const We &rw, + RT &x, RT &y ) +{ + RT dqw = RT(qw-pw); + RT drw = RT(rw-pw); + + weighted_circumcenter_translateC2(qx-px, qy-py, dqw,rx-px, ry-py,drw,x, y); + x += px; + y += py; +} + + +template < class RT , class We> +void +radical_axisC2(const RT &px, const RT &py, const We &pw, + const RT &qx, const RT &qy, const We &qw, + RT &a, RT &b, RT& c ) +{ + a = RT(2)*(px - qx); + b = RT(2)*(py - qy); + c = - CGAL_NTS square(px) - CGAL_NTS square(py) + + CGAL_NTS square(qx) + CGAL_NTS square(qy) + +RT(pw) - RT(qw); +} + + + } //namespace CGAL #endif // CGAL_CONSTRUCTIONS_KERNEL_FTC2_H diff --git a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h index 4600cd898b7..572516375a7 100644 --- a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h +++ b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h @@ -635,6 +635,71 @@ side_of_oriented_lineC2(const FT &a, const FT &b, const FT &c, return CGAL_NTS sign(a*x+b*y+c); } + +template +Comparison_result +compare_power_distanceC2(const FT& px, const FT& py, const FT& pwt, + const FT& qx, const FT& qy, const FT& qwt, + const FT& rx, const FT& ry) +{ + // returns SMALLER if r is closer to p w.r.t. the power metric + FT d1 = CGAL_NTS square(rx - px) + CGAL_NTS square(ry - py) - pwt; + FT d2 = CGAL_NTS square(rx - qx) + CGAL_NTS square(ry - qy) - qwt; + return CGAL_NTS compare(d1, d2); +} + + +template +Oriented_side +power_testC2( 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() ? + + // 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); +} + + +template +Oriented_side +power_testC2( 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; + + // 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); +} + + } //namespace CGAL #endif // CGAL_PREDICATES_KERNEL_FTC2_H diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h index 3106e63b1c5..d1ae0f1ca15 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h @@ -69,6 +69,7 @@ #include #include #include +#include #include #include diff --git a/Triangulation_2/include/CGAL/predicates/Regular_triangulation_rtH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH2.h similarity index 93% rename from Triangulation_2/include/CGAL/predicates/Regular_triangulation_rtH2.h rename to Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH2.h index 2fdb0a94677..3daa967cf1e 100644 --- a/Triangulation_2/include/CGAL/predicates/Regular_triangulation_rtH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH2.h @@ -1,10 +1,10 @@ // Copyright (c) 1999 INRIA Sophia-Antipolis (France). // All rights reserved. // -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. diff --git a/Triangulation_2/include/CGAL/constructions_on_weighted_points_homogeneous_2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/constructions_on_weighted_points_homogeneous_2.h similarity index 100% rename from Triangulation_2/include/CGAL/constructions_on_weighted_points_homogeneous_2.h rename to Homogeneous_kernel/include/CGAL/Homogeneous/constructions_on_weighted_points_homogeneous_2.h diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index c8eb831ef47..4ef069a5a39 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace CGAL { @@ -4285,6 +4286,9 @@ namespace HomogeneousKernelFunctors { return s.rep().orientation(); } }; + + + template < typename K > class Power_side_of_power_sphere_3 { diff --git a/Triangulation_2/include/CGAL/Regular_triangulation_euclidean_traits_2.h b/Triangulation_2/include/CGAL/Regular_triangulation_euclidean_traits_2.h index 27967c2ea82..c9fcfb9e541 100644 --- a/Triangulation_2/include/CGAL/Regular_triangulation_euclidean_traits_2.h +++ b/Triangulation_2/include/CGAL/Regular_triangulation_euclidean_traits_2.h @@ -29,11 +29,6 @@ #include #include -#include -#include - -#include -#include namespace CGAL { diff --git a/Triangulation_2/include/CGAL/predicates/Regular_triangulation_ftC2.h b/Triangulation_2/include/CGAL/predicates/Regular_triangulation_ftC2.h deleted file mode 100644 index 0bde1702333..00000000000 --- a/Triangulation_2/include/CGAL/predicates/Regular_triangulation_ftC2.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 1999 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Sylvain Pion -// Mariette Yvinec - -#ifndef CGAL_REGULAR_TRIANGULATION_FTC2_H -#define CGAL_REGULAR_TRIANGULATION_FTC2_H - -#include - -// This file contains the low level cartesian predicates -// used by the 2D regular triangulation. - -namespace CGAL { - -template -Comparison_result -compare_power_distanceC2(const FT& px, const FT& py, const FT& pwt, - const FT& qx, const FT& qy, const FT& qwt, - const FT& rx, const FT& ry) -{ - // returns SMALLER if r is closer to p w.r.t. the power metric - FT d1 = CGAL_NTS square(rx - px) + CGAL_NTS square(ry - py) - pwt; - FT d2 = CGAL_NTS square(rx - qx) + CGAL_NTS square(ry - qy) - qwt; - return CGAL_NTS compare(d1, d2); -} - - -template -Oriented_side -power_testC2( 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() ? - - // 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); -} - - -template -Oriented_side -power_testC2( 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; - - // 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); -} - -} //namespace CGAL - -#endif // CGAL_REGULAR_TRIANGULATION_FTC2_H