3

Question: How to "divide polygon" to create quads adjacent to the each segment.

My 1st idea: Divide each segment of polygon. Move each newly created point - perpendicular to divided segment. Now we get points for quads. At the end - remove overlapped quads. Questions: How to check if each (new) point of quad is inside polygon? Because the newly created points can go beyond the polygon - specifically on corners. Also how to check overlapped quads?

My 2nd idea: Inset polygon. Divide segments then connect points. But how about more complex polygons where some segments after inset can intersect?

I know this is more a math problem but I'm looking for ready-made solutions for above problems - like simple 2d collision detection of rectangles (but not only one axis aligned).

Maybe someone have better ideas how to create procedural urban parcels?

user3688059
  • 160
  • 1
  • 8
  • Can you say more about the purpose of these generated parcels? It's possible that Delaunay triangulation or some variant of it will server your needs. – O. Jones Jan 24 '15 at 14:33
  • I think your 1st idea will work fine. Your quads are always convex polygons, so all you have to do is calculate the intersection of two convex polygons in order to find out if a new quad will overlap an existing quad. Just do a search for how to calculate the intersection of convex hulls or convex polygons. – RogerN Jan 24 '15 at 14:48
  • Ollie I need this solution to create simple maps. Yeah I was thinking about triangulation also but I only want parcels adjacent to polygon segments. Triangulation is (for me) not easy to control. RogerN I think the same but in some cases it would be nice to get just one big parcel when segments are close enough. I know how to check this but its always worth asking for other ideas. – user3688059 Jan 24 '15 at 15:04
  • a tip: http://www.angusj.com/delphi/clipper.php ClipperLib has helped me tremendously with polygons – thumbmunkeys Jan 24 '15 at 15:41

1 Answers1

0

Do they have to be quads? That is a pretty serious restriction, especially when dealing with arbitrary geometries like in your picture.

For something like this, I would try using Voronoi diagram to partition the space. A Voronoi diagram algorithm takes a set of points as inputs and partitions the space so that each input point is associated with a region of space where all the points inside that region are closest to that input point. For your inputs you could put two sets of points on the interior of your polygon, one set closest to the edge which contains the regions you will use, and the second set of points will be that interior area that you will discard.

Have a look at the Fortune Voronoi implementation in C#.

Erik
  • 5,355
  • 25
  • 39