CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.68k stars 1.35k forks source link

Wrong result for do_intersect between a segment and a triangle if segment degenerate #8146

Open LeoValque opened 2 months ago

LeoValque commented 2 months ago

Issue Details

The do_intersect function returns the wrong result between a segment and a triangle if the segment is degenerate. I tried it on my colleague's machine to make sure the error didn't come from mine. The expected result is "000" or a precondition violation and the output is "010". A precondition is probably missing.

Source Code

include <CGAL/Exact_predicates_exact_constructions_kernel.h>

include <CGAL/intersections.h>

typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef K::Point_2 Point_2; typedef K::Triangle_2 Triangle_2; typedef K::Segment_2 Segment_2;

int main(){ Triangle_2 tr_normal(Point_2(-1,0),Point_2(0,0),Point_2(1,7)); Point_2 p(0.5,-1);

Segment_2 seg_normal(p,Point_2(0.5,2));
Segment_2 seg_deg(p,p);

std::cout << CGAL::do_intersect(tr_normal,seg_normal)<< std::endl;
std::cout << CGAL::do_intersect(tr_normal,seg_deg)<< std::endl;
std::cout << CGAL::do_intersect(tr_normal,p)<< std::endl;
return 0;

}

Environment