From fbf588e936ce41a1ef0cdf0ba17502c65fe6295c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Valque?= Date: Thu, 27 Feb 2025 10:58:53 +0100 Subject: [PATCH] Get back on CSQ Point-Segment, new was slower --- .../CGAL/Distance_3/Point_3_Segment_3.h | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/Distance_3/include/CGAL/Distance_3/Point_3_Segment_3.h b/Distance_3/include/CGAL/Distance_3/Point_3_Segment_3.h index aa76b52e66c..f13fa5ae5de 100644 --- a/Distance_3/include/CGAL/Distance_3/Point_3_Segment_3.h +++ b/Distance_3/include/CGAL/Distance_3/Point_3_Segment_3.h @@ -116,38 +116,7 @@ compare_squared_distance(const typename K::Point_3& pt, const K& k, const typename K::FT& d2) { - typedef typename K::RT RT; - typedef typename K::FT FT; - typedef typename K::Vector_3 Vector_3; - - typename K::Construct_vector_3 vector = k.construct_vector_3_object(); - typename K::Compare_squared_distance_3 csq_dist = k.compare_squared_distance_3_object(); - - // assert that the segment is valid (non zero length). - const Vector_3 diff = vector(seg.source(), pt); - const Vector_3 segvec = vector(seg.source(), seg.target()); - - // If the segment is degen - if(seg.source()==seg.target()) - return csq_dist(pt, seg.source(), d2); - - // Compare first the distance to the line, if larger we can exit early - const typename K::Comparison_result res_pl= compare_squared_distance_to_line(segvec, diff, k, d2); - if(res_pl==LARGER) - return LARGER; - - //If the distance is realized by the source - const RT d = wdot(diff, segvec, k); - if(d <= RT(0)) - return compare(FT(diff*diff), d2); - - //If the distance is realized by the target - const RT e = wdot(segvec, segvec, k); - if(wmult((K*)0, d, segvec.hw()) > wmult((K*)0, e, diff.hw())) - return csq_dist(pt, seg.target(), d2); - - //If the distance is realized by the interior - return res_pl; + return compare(squared_distance(pt, seg, k), d2); } template