I want to create Voronoï cells inside of an unconstrained enclosing shape (convex, concave, doesn't matter).
I found an implementation of Fortune's algorithm in C# here, and got some results:
Convex envelope: [attachment=16782:voronoi convex.png]
In the screenshots the white polygon is my envelope (hand-defined), the magenta points are the cell centers (hand-defined also), and the tiny red points + blue lines are Fortune's results.
I feed the algorithm all the points (envelope + cell centers), so I guess it considers the envelope points as cell centers as well; I haven't found anything that would specify that the envelope is only a boundary.
As you can see with a convex shape the result is kinda satisfying, I could more or less see how to finish the job (add some cells to fill the holes, cut some out-of-bounds triangles). But with the concave one there are many Voronoï vertices outside of the envelope, I would have to cut a lot of crap and then end up with concave cells in some cases... and I haven't even yet tried it with some really bad shapes. Anyway I believe this algorithm generates a convex hull of the point soup as by-product of the computation, or even uses it somehow, so I can't see it playing well with concave.
All in all it doesn't seem like this algorithm is quite right for the job: any ideas?
On a side-note, I'd like the cell centers to be randomly generated: how can I generate random points inside of any shape? A dumb solution would be to randomize inside the AABB and then check if the point is inside, repeat if not, but maybe a better solution exists?