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?


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]


voronoi // InputForm

or rebuilding

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.