Skip to content

Commit

Permalink
Merge pull request #7118 from sloriot/Intersections_2-vert_hori_segments
Browse files Browse the repository at this point in the history
Add special case for intersection of a vertical segment with an horizontal segment
  • Loading branch information
lrineau committed Feb 10, 2023
2 parents 4e941a1 + 397620e commit cb68949
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,22 @@ Segment_2_Segment_2_pair<K>::intersection_type() const
: CGAL::make_array( _seg2->point(s2s2_id[c][2]), _seg2->point(s2s2_id[c][3]),
_seg1->point(s2s2_id[c][0]), _seg1->point(s2s2_id[c][1]) );

// special case for vertical and horizontal segments
if (std::is_floating_point<typename K::FT>::value &&
std::is_same<typename K::Kernel_tag, Cartesian_tag>::value)
{
if (pts[0].x()==pts[1].x() && pts[2].y()==pts[3].y())
{
_intersection_point = K().construct_point_2_object()(pts[0].x(), pts[2].y());
return _result;
}
if (pts[0].y()==pts[1].y() && pts[2].x()==pts[3].x())
{
_intersection_point = K().construct_point_2_object()(pts[2].x(), pts[0].y());
return _result;
}
}

typename K::FT alpha = s2s2_alpha(pts[0].x(), pts[0].y(), pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y(), pts[3].x(), pts[3].y());

_intersection_point = K().construct_barycenter_2_object()(pts[0], alpha, pts[1]);
Expand Down

0 comments on commit cb68949

Please sign in to comment.