Boost geometry : intersection using an open interval
up vote
0
down vote
favorite
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?
c++ boost computational-geometry boost-geometry
add a comment |
up vote
0
down vote
favorite
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?
c++ boost computational-geometry boost-geometry
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?
c++ boost computational-geometry boost-geometry
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?
c++ boost computational-geometry boost-geometry
c++ boost computational-geometry boost-geometry
asked Nov 21 at 19:56
user129186
374519
374519
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
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;
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 at 21:42
@user129186, I thought you wanted to avoid detecting intersection in the common point. But maybe you want to check if adjacent segments partially coincide with red segment?
– trollingchar
Nov 21 at 22:15
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
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;
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 at 21:42
@user129186, I thought you wanted to avoid detecting intersection in the common point. But maybe you want to check if adjacent segments partially coincide with red segment?
– trollingchar
Nov 21 at 22:15
add a comment |
up vote
0
down vote
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;
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 at 21:42
@user129186, I thought you wanted to avoid detecting intersection in the common point. But maybe you want to check if adjacent segments partially coincide with red segment?
– trollingchar
Nov 21 at 22:15
add a comment |
up vote
0
down vote
up vote
0
down vote
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;
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;
answered Nov 21 at 21:12
trollingchar
1616
1616
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 at 21:42
@user129186, I thought you wanted to avoid detecting intersection in the common point. But maybe you want to check if adjacent segments partially coincide with red segment?
– trollingchar
Nov 21 at 22:15
add a comment |
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 at 21:42
@user129186, I thought you wanted to avoid detecting intersection in the common point. But maybe you want to check if adjacent segments partially coincide with red segment?
– trollingchar
Nov 21 at 22:15
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 at 21:42
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 at 21:42
@user129186, I thought you wanted to avoid detecting intersection in the common point. But maybe you want to check if adjacent segments partially coincide with red segment?
– trollingchar
Nov 21 at 22:15
@user129186, I thought you wanted to avoid detecting intersection in the common point. But maybe you want to check if adjacent segments partially coincide with red segment?
– trollingchar
Nov 21 at 22:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419620%2fboost-geometry-intersection-using-an-open-interval%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown