5
$\begingroup$

I am trying to compute a Voronoi diagram bounded by a box. In some cases, the points used to compute the diagram form a diagram such that at least two boundary points are within the same polygon. For Example:

centres = {{0, 1250}, {4750, 2000}, {-2500, -2500}, {500, 750}}; boundaries = {{10000, 10000}, {-10000, 10000}, {-10000, -10000}, {10000, -10000}}; {diagvert, diagval} = BoundedDiagram[boundaries, centres]; 

With the Voronoi diagram:

enter image description here

This leads to the error:

BoundedDiagram::notuniq: BoundedDiagram requires that boundary vertices lie in unique Voronoi polygons.

Since I am trying to generalize the scenario, I can't design a specific boundary for the points, and I would like to use a general big enough boundary. Is there any way to allow multiple boundary points within the same polygon? Or perhaps a different approach?

$\endgroup$
0

1 Answer 1

8
$\begingroup$

If I understood correctly that bounding box needs to be automated, you can just use this trick:

centres = RandomReal[1, {50, 2}]; voronoi = ListDensityPlot[Append[#, 0] & /@ centres, InterpolationOrder -> 0, BoundaryStyle -> Black, Frame -> False, ColorFunction -> (White &)] 

enter image description here

Then information about Polygons and other geometry is available as

Cases[voronoi, _Polygon, Infinity] 

or

voronoi // InputForm 

or rebuilding

Graphics[{FaceForm[], EdgeForm[Black], GraphicsComplex[voronoi[[1, 1]], Cases[voronoi, _Polygon, Infinity]]}] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.