Re: Polygon-Polygon Intersection Test



On 2006-03-14, shu.miah@xxxxxxxxxxxxxx <shu.miah@xxxxxxxxxxxxxx> wrote:
After an extensive search and going through alot of material I've had
very little success.

I have a set of verticies of two simple polygons (which can be convex
[or concave]) and I wish to do a test to see whether the two polygons
intersect (i.e return a boolean value)...

I think it's quite easy.

It's no good to just have the vertices, because if the polygons can be
non-convex, a given set of vertices could be joined up in different ways
to make different polygons.

So you also need to know the edges to start with (i.e. which order to
join the vertices up in). Otherwise your problem is impossible.

The edges are line segments, so you have two sets of line segments, one
for each poly. If any line segment in one of the sets crosses any of the
line segments in the other set, then the polygons intersect. Otherwise
they don't.

So:

foreach a in A:
foreach b in B:
if a intersects b: return true
return false

is your basic program

Then all you have to worry about is how to intersect two linesegments,
which isn't too hard.

Some of the algorithms for convex polygons are more sophisticated,
basically because you can do some clever optimizations on this nested
loop based on the fact that they're convex.
.



Relevant Pages

  • Re: Searching Neighbour Polygon
    ... concave into convex polygons. ... The standard terminology is to call these "polyhedra", ... are built as "generalized cylinders" from 2D polygons. ... decomposition of the 2D polygon that generated the polyhedron. ...
    (comp.graphics.algorithms)
  • Re: Searching Neighbour Polygon
    ... The standard terminology is to call these "polyhedra", ... does clipping for a convex and a concave/convex polygon, ... as I could have to concave polygons. ... decomposition of the 2D polygon that generated the polyhedron. ...
    (comp.graphics.algorithms)
  • Re: Fortran Code or Algorithm for Polygon Clipping ?
    ... > is there some code in Fortran available for the clipping of convex ... This code uses a Sutherland-Hodgman clipping alogrithm ... It only works for convex polygons. ...
    (comp.lang.fortran)
  • Re: Intersection points of two convex polygon .
    ... Given two convex polygons, they may or may not intersect. ... i am trying to solve computational geomery problem ... Find the intersections of all line segments of P and Q ...
    (sci.math)
  • Re: Finding closest Triangle to a point
    ... all its polygons are contained in the boundary of the convex hull ... formed by the vertices of the mesh. ...
    (comp.graphics.algorithms)