I have a polyline and a line segment. One of the endpoints of the line segment is always also a point of the polyline.
Example: line segment: (1,2),(3,3) polyline: (3,3),(10,10),(15,30)
I want to use boost geometry in order to find whether the line segment and the polyline have an intersection. However, it is okay for them to intersect at the connected point. In this case, (3,3).
boost::geometry::intersects
will always return true
in this case. I would like to make an exception for the common point, but still have it return true
if there is an intersection at any other point. Is there a clever way to go about this? Or do I have to use boost::geometry::intersection
and iterate over the results?
If I understood you correctly, you want to check if the segment intersects with polyline in point other than its connected point.
So you need to check only segments that do not have shared endpoint with red segment (see picture). You may skip those who do have same endpoint with red segment or you may want to handle them in a different way, for example, check if entire segments coincide.
I didn't work with c++ for a long time so I write pseudo code:
foreach (segment in polyline) {
if (
segment.A != redSegment.A &&
segment.A != redSegment.B &&
segment.B != redSegment.A &&
segment.B != redSegment.B &&
intersect (segment, redSegment)
) {
return true;
}
}
return false;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.