Boost geometry : intersection using an open interval
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 |
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 |
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 '18 at 19:56
user129186user129186
404619
404619
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 '18 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 '18 at 22:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 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 '18 at 22:15
add a comment |
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 '18 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 '18 at 22:15
add a comment |
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 '18 at 21:12
trollingchartrollingchar
3187
3187
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 '18 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 '18 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 '18 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 '18 at 22:15
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 '18 at 21:42
This solution will unfortunately miss any intersections on the adjacent polyline segments of the common point.
– user129186
Nov 21 '18 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 '18 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 '18 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.
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