4

This is a follow-up question to How to test if a line intersects a convex polygon?

Lets say I am able to test if a line intersects a convex polygon or not (I'm still not sure what's the best method, and this question is linked with my difficulty). What I want to do is this: If I find that the line intersects the polygon, I want to maintain either the left or right polygon that is created. I'm not sure how to maintain the polygon object so that the above is easy to compute.

enter image description here

To summarize, given a polygon object and a line, how do I find the new polygon that is created by intersecting the halfplane-created-by-the-line with the polygon? Does CGAL or any other library have a ready-to-use function for this? If I have to code this from scratch, how should I maintain the polygon object?

Community
  • 1
  • 1
elexhobby
  • 2,588
  • 5
  • 24
  • 33
  • I don't see how you're creating a new polyhedron here. Do you mean that you're taking the intersection of a polyhedron with a *plane* rather than a line? A single line isn't going to divide a polyhedron into two parts. – Mark Dickinson Apr 23 '15 at 19:30
  • @MarkDickinson: you are right, my bad. I want to take the intersection of the polyhedron with either the left or right halfspace created by the line. – elexhobby Apr 23 '15 at 19:34
  • But how does a line create a halfspace? You are working in three dimensions, right? – Mark Dickinson Apr 23 '15 at 19:42
  • No. I'm working in 2d. By halfspace, I mean halfplane. Sorry, I'm not aware of the standard terminology used in CG. – elexhobby Apr 23 '15 at 19:43
  • Ah. Then you probably want to rephrase your question to talk about polygons rather than polyhedra. – Mark Dickinson Apr 23 '15 at 19:48
  • Maybe. But one of the answerers on my previous question said that polygons refer to bounded closed polygons. Unbounded polygons are referred to as polyhedra/polytopes. And I want to consider the unbounded case. – elexhobby Apr 23 '15 at 19:52
  • I suggest you ignore that answer: "polyhedron" pretty much always means a 3-dimensional object. (polytope *is* more general, though). But don't take my word for it: look up polyhedron any place and see what definition you get. :-) – Mark Dickinson Apr 23 '15 at 20:25

1 Answers1

0

I think one solution using CGAL could be to use the 2D Boolean Operations on Nef Polygons. But for convex polygons, that might be an overkill. What bothers me is that you mention that you might want to use unbounded convex polygons. Without Nef polygons, I do not know if one can represent that in CGAL.

lrineau
  • 6,036
  • 3
  • 34
  • 47