Error with VoronoiDiagram[] function

In summary, the VoronoiDiagram[] function can fail if the coordinates provided are not precise enough. Using N[] with a proper precision can help solve the issue. Other methods for calculating a Brillouin zone given a list of coordinates may also be available.
  • #1
guerom00
93
0
Hello everyone,

I have a list of (x,y) coordinates for 9 points i.e.

{{-9.896, -5.1406}, {-6.2832, 0.}, {-2.6703,
5.1406}, {-3.6129, -5.1406}, {0., 0.}, {3.6129,
5.1406}, {2.6703, -5.1406}, {6.2832, 0.}, {9.896, 5.1406}}.

I use the VoronoiDiagram[] function (I use that to calculate a Brillouin zone...) and it works fine :

{{{-6.8348, -3.4825}, {-3.1416, -1.6007}, {-3.1416,
1.6007}, {-0.55157, -3.4825}, {0.55157,
3.4825}, {3.1416, -1.6007}, {3.1416, 1.6007}, {6.8348, 3.4825},
Ray[{-6.8348, -3.4825}, {-13.213, 1.1516}],
Ray[{-6.8348, -3.4825}, {-6.8348, -11.366}],
Ray[{-3.1416, 1.6007}, {-9.5198, 6.2348}],
Ray[{0.55157, 3.4825}, {0.55157, 11.366}],
Ray[{-0.55157, -3.4825}, {-0.55157, -11.366}],
Ray[{6.8348, 3.4825}, {6.8348, 11.366}],
Ray[{3.1416, -1.6007}, {9.5198, -6.2348}],
Ray[{6.8348, 3.4825}, {13.213, -1.1516}]}, {{1, {1, 9, 10}}, {2, {1,
2, 3, 11, 9}}, {3, {3, 5, 12, 11}}, {4, {4, 2, 1, 10,
13}}, {5, {3, 2, 4, 6, 7, 5}}, {6, {5, 7, 8, 14, 12}}, {7, {6, 4,
13, 15}}, {8, {8, 7, 6, 15, 16}}, {9, {8, 16, 14}}}}

However, for slightly different coordinates for my nine points :

{{-9.8871, -5.1469}, {-6.2832, 0.}, {-2.6793,
5.1469}, {-3.6039, -5.1469}, {0., 0.}, {3.6039,
5.1469}, {2.6793, -5.1469}, {6.2832, 0.}, {9.8871, 5.1469}}

the VoronoiDiagram[] function fails as

10/21/10 18:01:42 During evaluation of (Main) In[34]:= First::first: {} has a length of zero and no first element. >>

10/21/10 18:01:43 During evaluation of (Main) In[34]:= Power::infy: Infinite expression 1/0. encountered. >>

10/21/10 18:01:43 During evaluation of (Main) In[34]:= \[Infinity]::indet: Indeterminate expression 0. ComplexInfinity encountered. >>

10/21/10 18:01:43 During evaluation of (Main) In[34]:= \[Infinity]::indet: Indeterminate expression 0. ComplexInfinity encountered. >>

10/21/10 18:01:43 (Main) Out[37]= {{{-8.,
2.}, {-6.7455, -3.5115}, {-3.1416, -1.6354}, {-3.1416,
1.6354}, {-0.46229, -3.5115}, {0.46229,
3.5115}, {5.8209, -0.24066}, {6.7455,
3.5115}, {6.7455, -0.3237}, {8., -2.}, {Indeterminate,
Indeterminate}, Ray[{-8., 2.}, {-18.655, 8.6626}],
Ray[{-6.7455, -3.5115}, {-6.7455, -11.43}],
Ray[{0.46229, 3.5115}, {0.46229, 11.43}],
Ray[{-0.46229, -3.5115}, {-0.46229, -11.43}],
Ray[{6.7455, -0.3237}, {6.7455, 11.43}],
Ray[{6.7455, -0.3237}, {17.039, -7.5315}]}, {{1, {2, 1, 12,
13}}, {2, {2, 3, 4, 1}}, {3, {1, 4, 6, 14, 12}}, {4, {5, 3, 2, 13,
15}}, {5, {4, 3, 5, 7, 6}}, {6, {6, 7, 9, 16, 14}}, {7, {9, 7, 5,
15, 17}}, {8, {{8, 9, 9}}}, {9, {8, 9, 10}}}}

Obviously, it means that the VoronoiDiagram[] function is not robust... Any idea how to solve this issue ? Or does anyone knows of another method to calculate a Brillouin zone given a list of coordinates ?

Thanks in advance :)
 
Physics news on Phys.org
  • #2
</code>Thanks for your help.I found out the solution. It was a problem of precision. I used N[], with a precision of 8 digits, to round off my coordinates and then the VoronoiDiagram[] function worked fine. {{{-9.8871, -5.1469}, {-6.2832, 0.}, {-2.6793, 5.1469}, {-3.6039, -5.1469}, {0., 0.}, {3.6039, 5.1469}, {2.6793, -5.1469}, {6.2832, 0.}, {9.8871, 5.1469}} became{{{-9.8871, -5.1469}, {-6.2832, 0.}, {-2.6793, 5.1469}, {-3.6039, -5.1469}, {0., 0.}, {3.6039, 5.1469}, {2.6793, -5.1469}, {6.2832, 0.}, {9.8871, 5.1469}}and it worked fine. Thanks for all your help :)
 

Related to Error with VoronoiDiagram[] function

1. What is the VoronoiDiagram[] function and how does it work?

The VoronoiDiagram[] function is a mathematical algorithm used to generate a Voronoi diagram, which is a type of diagram that divides a plane into regions based on the distance to a set of points. This function takes in a set of points as input and outputs a diagram with polygons representing the regions. It works by calculating the distance from each point to its nearest neighbor and drawing a line perpendicular to that line, creating the polygon boundaries.

2. Why am I getting an error with the VoronoiDiagram[] function?

There could be several reasons for an error with the VoronoiDiagram[] function. Some common reasons include incorrect input format, such as providing a set of points that do not form a valid diagram, or using an outdated or incompatible version of the function. It is also possible that there is a bug in the function itself, in which case you can report it to the developers for further investigation.

3. How can I fix an error with the VoronoiDiagram[] function?

The first step to fixing an error with the VoronoiDiagram[] function is to carefully check your input and make sure it is in the correct format. If you are still getting an error, try updating to the latest version of the function or using a different programming language or software that implements the function. If none of these solutions work, you can reach out to the developers for assistance or look for alternative methods to generate a Voronoi diagram.

4. Can the VoronoiDiagram[] function handle large datasets?

Yes, the VoronoiDiagram[] function can handle large datasets. However, the time and memory required to generate the diagram will depend on the number of points in the dataset. If you are working with a very large dataset, it may be necessary to optimize your code or use a more efficient algorithm to generate the diagram.

5. Are there any limitations to the VoronoiDiagram[] function?

Like any mathematical function, the VoronoiDiagram[] function has its limitations. One limitation is that it can only generate diagrams in two dimensions. Additionally, the function may not be able to handle certain types of datasets, such as non-convex or degenerate datasets, which can lead to errors or incorrect results. It is important to carefully consider your input and choose the appropriate method for generating a Voronoi diagram based on your specific needs.

Similar threads

  • Nuclear Engineering
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
477
  • Nuclear Engineering
Replies
7
Views
2K
  • Precalculus Mathematics Homework Help
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Replies
6
Views
2K
  • Precalculus Mathematics Homework Help
Replies
6
Views
1K
  • General Math
Replies
24
Views
2K
  • Nuclear Engineering
Replies
7
Views
990
  • Precalculus Mathematics Homework Help
Replies
1
Views
1K
Back
Top