diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index d37e412ee40..19d29f76557 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -4322,18 +4322,13 @@ namespace CartesianKernelFunctors { const Point_2& p2 = vertex(t, 2); CGAL_assertion(p0 != p1 && p1 != p2 && p2 != p0); - const FT dX = b.x() - a.x(); - const FT dY = b.y() - a.y(); - const FT R0 = p0.x() * p0.x() + p0.y() * p0.y(); - const FT R1 = p1.x() * p1.x() + p1.y() * p1.y(); - const FT R2 = p2.x() * p2.x() + p2.y() * p2.y(); - const FT denominator = (p1.x() - p0.x()) * (p2.y() - p0.y()) + - (p0.x() - p2.x()) * (p1.y() - p0.y()); - const FT det = 2 * denominator * (a.x() * dY - a.y() * dX) - - (R2 - R1) * (p0.x() * dX + p0.y() * dY) - - (R0 - R2) * (p1.x() * dX + p1.y() * dY) - - (R1 - R0) * (p2.x() * dX + p2.y() * dY); - return CGAL::sign(det); + return circumcenter_oriented_side_of_oriented_segmentC2( + a.x(), a.y(), + b.x(), b.y(), + p0.x(), p0.y(), + p1.x(), p1.y(), + p2.x(), p2.y() + ); } }; diff --git a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h index 7e49bb62376..e6da15d2547 100644 --- a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h +++ b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h @@ -708,6 +708,28 @@ power_side_of_oriented_power_circleC2(const FT &px, const FT &py, const FT &pwt, return cmpy * sign_of_determinant(dpy, dpz, dqy, dqz); } +template +Oriented_side +circumcenter_oriented_side_of_oriented_segmentC2(const FT& ax, const FT& ay, + const FT& bx, const FT& by, + const FT& p0x, const FT& p0y, + const FT& p1x, const FT& p1y, + const FT& p2x, const FT& p2y) +{ + const FT dX = bx - ax; + const FT dY = bx - ay; + const FT R0 = p0x * p0x + p0x * p0x; + const FT R1 = p1x * p1x + p1x * p1x; + const FT R2 = p2x * p2x + p2x * p2x; + const FT denominator = (p1x - p0x) * (p2x - p0x) + + (p0x - p2x) * (p1x - p0x); + const FT det = 2 * denominator * (ax * dY - ay * dX) + - (R2 - R1) * (p0x * dX + p0x * dY) + - (R0 - R2) * (p1x * dX + p1x * dY) + - (R1 - R0) * (p2x * dX + p2x * dY); + return CGAL::sign(det); +} + } //namespace CGAL #endif // CGAL_PREDICATES_KERNEL_FTC2_H