1
$\begingroup$

Is it possible to generate a periodic Voronoi Mesh inside a rectangular domain? I would also like to obtain the coordinates of each cell separately so that I can perform further operations on each cell.

Edit: The following code as mentioned in this post seems to work fine to generate a periodic pattern.

(* Initial Data *)
SeedRandom[1];
pts = RandomReal[{-1, 1}, {10, 2}];
(* Augment data and find the larger Voronoi Mesh *)

pts2 = Flatten[
   Table[TranslationTransform[{2 i, 2 j}][pts], {i, -1, 1}, {j, -1, 
     1}], 2];
vor1 = VoronoiMesh[pts2, {{-3, 3}, {-3, 3}}]
vor2 = VoronoiMesh[pts2, {{-1, 1}, {-1, 1}}];
coord = MeshCoordinates[vor2];
Show[vor2, Graphics[{Red, PointSize[0.01], Point[coord]}]]

enter image description here enter image description here

Getting all the coordinates is easily done with MeshCoordinates. However, getting the group of coordinates separately for each cell is what I am looking for.

$\endgroup$
7
  • 1
    $\begingroup$ The expensive way is to periodically pad your data, compute the usual Voronoi diagram, and crop back. $\endgroup$ – J. M.'s ennui May 26 '20 at 4:02
  • $\begingroup$ How about the second part of the question? How do I go about obtaining the coordinates of each cell separately?Eventually, I would like to perform a self-similar contraction of each cell so as to create parallel gaps between each cell. I guess if I have coordinates of each cell, perform the self-similar transformation would be easy. $\endgroup$ – Pinkesh May 26 '20 at 12:54
  • $\begingroup$ That depends. Are you fine with a cell near a corner of the rectangular domain being split into four different polygons? Also, have you seen this already? $\endgroup$ – J. M.'s ennui May 26 '20 at 12:56
  • $\begingroup$ Yes, the splitting should be fine. I have seen the post, the first part of the question seems to work but extracting the coordinates separately for each cell is where I am stuck at. $\endgroup$ – Pinkesh May 26 '20 at 19:03
  • 1
    $\begingroup$ MeshPrimitives maybe? $\endgroup$ – Chip Hurst May 26 '20 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.