I want to draw a Voronoi diagram with 9 sites and with
1. no vertex
2. 1 vertices
3. 4 vertices
4. 7 vertices.
How do I approach this question. The one with no vertex is easy, it can be done by collinear points.
What about the others.
A figure for each would be appreciated.
Simple examples are:
4 vertices: Tic-tac-toe configuration,
7 vertices: configuration of sites on 3 rays going from same
point equidistantly positioned. Vertices are ray origin point and 3 times by 2
vertices between rays.
Related
I have a list of 8 points given by their coordinates (x, y, z).
These 8 points are the 8 vertices of an hexahedron, which means that there are 6 faces which are quadrilaterals; the 4 points on each face are guaranteed to be coplanar.
I want to sort the list of points in a particular order:
the first 4 points must be on the same face, and in counterclockwise order;
the next 4 points must be their corresponding points on the opposite face.
Example:
I found similar question asked, but this algorithm fails on this example hexahedron:
I also have an idea to sort points in direct way by finding points in the same plane, then the other point in this plane, then point on same edge and etc.
But is there any easier way to order these points?
When getting the vertices of an H3 cell using H3toGeoBoundary, how many possible vertex configurations can the GeoBoundary struct produce? I count four:
6 vertices: regular hexagon
5 vertices: regular pentagon
7 vertices: irregular hexagon (https://observablehq.com/#nrabinowitz/h3-index-inspector#85080013fffffff)
10 vertices: irregular pentagon (https://observablehq.com/#nrabinowitz/h3-index-inspector#85080003fffffff%0A%0A)
Is this list exhaustive or can other configurations exist? Would it also ever produce 0?
Your list is missing the 8 vertices case. Rather than using the generic term "irregular", it's more accurate to consider extra distortion vertices: At odd resolutions, cell edges that cross an edge of the icosahedron will have additional distortion vertices added to account for the change in projection plane (at even resolutions, the cells are aligned with the icosahedron edges and do not require this). With that explanation, the list looks like this:
5 vertices: even-resolution pentagon cell (8408001ffffffff)
6 vertices: standard hexagon cell (85283473fffffff)
7 vertices: hexagon cell with an icosahedron edge crossing one vertex and one edge (85080013fffffff)
8 vertices: hexagon cell with an icosahedron edge crossing two edges (850802a3fffffff)
10 vertices: odd-resolution pentagon cell (85080003fffffff)
Note that we still use "pentagon" and "hexagon" to describe these cells, because that's still topologically correct (a pentagon always has 5 neighbors, a hexagon always has 6).
Before I go into my problem, here are some definition that might be helpful:
A diagonal of a polygon P is a segment that joins two vertices of P and remains strictly inside P.
Steiner point: an extra point added to a vertex set that was not part of the original set, e.g. the vertex 7 in the polygon as shown in Fig. 1.
A link path is a polyline that is completely inside a polygon. The link path could be a diagonal of a polygon or a collection of line segments. For example, the line segment shown in red dash in Fig. 1 is not completely inside the polygon (intersect with other edge), we add a Steiner point, 7, using the algorithm here such that we have a 2-link path connect vertex 2 and 5.
We have two simple polygons without holes with the corresponding vertices labeled as 1, 2, …, n.
Let us first look at the simplified problem. As shown in Fig. 2, we have two polygons P and Q. I want to start from the concave polygon P and decompose P into a set of convex sub-polygons using only diagonals without introducing any Steiner points into polygon P. At the same time, we also find the link path in the other polygon Q using the same vertex pair in polygon Q.
For example, we use the diagonal connecting vertex 2 and 5 in P to partition P as shown in Fig. 3. We find the link path that connects vertex 2 and 5 in polygon Q, which introduces a Steiner point 7. (Here, let us just assume we can always find the link path in polygon Q with the smallest number of Steiner points needed)
We want to partition polygon P using diagonals of P while introducing the smallest number of Steiner points into polygon Q. We iteratively decompose P and Q until all the sub-polygon pairs contain a convex polygon. For example, in Fig. 3, sub-polygon pair P_{2345} and Q_{2345} has already contains a convex polygon P_{2345} and we do not need to decompose them anymore. Then, we need to consider sub-polygon pair P_{1256} and Q_{1256} as either of them is convex.
Here is one example of partitioning polygon P and Q with one Steiner point 7 as shown in Fig. 4.(We add a corresponding point 7 on the diagonal that connects vertex 2 and 5 in P based a linear ratio. The linear ratio is computed by the length of line segment (2,7) in polygon Q overt the total length of the link path that connects vertex 2 and 5 in Q.)
Here are some more cases on convexly decompose polygon P and Q as shown in Fig. 5.
More general problem:
(1) At the beginning, we can start from either polygon P or Q.
(2) During the partition process, we can also starting from the other corresponding sub-poly.
For example, at the beginning, we start from polygon P to decompose P using diagonal that connecting vertex 2 and 4 in P. Then, for sub-polygon pair P_{12456} and Q_{12456}, we could start from Q_{12456} instead of P_{12456} for decomposing. Say, we pick diagonal that connecting vertex 4 and 6 in Q shown in Fig. 6.
I realized that if I want to find the optimum solution there would be exponential combinations. My question is, is there any algorithm can speed it up?
I have a volume mesh which is actually a tetrahedral mesh. I would like to calculate the cross-section of this mesh given a plane function, saying z = 0. I can imagine that the cross section of a tetrahedron is either a triangle or a quadrilateral. For the first case, triangle, once I calculate the 3 cross points I can get it; but for the second case, how can I make the quadrilateral become 2 triangles? My problem is I cannot determine the diagonal of the quadrilateral.
Intersect all tetrahedron edges by the plane. You will get 3 or 4 intersection points.
If 3 points then a single triangle.
If 4 points, they form a convex quadrilateral. Take any 3 points, that form a first triangle. The other triangle if formed of the fourth point and the two endpoints of the edge that has this point to its right.
Alternatively (for a more general solution), tag the intersection points with the indexes of the faces incident on the edge, and reconstruct the ring of labels.
Ex: edges are common to faces AB, CD, DA and BC; then the section is ABCD.
This answer outlines a general volume-plane intersection algorithm. It will return the vertices of the intersection in order, so it's easy to determine the diagonal of your quadrilateral.
My goal is to get the individual 3D Voronoi cells (both vertices and edges) from the output of Qhull's qvoronoi subroutine. However, I'm having trouble understanding the voronoi ridges (output 'Fv'). A sample line from the output is:
7 0 1 1 0 4 5 3
The first number is the number of vertices in the line, the next two are the indices of the vertices separated by the ridge, and the rest of the numbers are the vertex indices on the ridge. I naively tried connecting adjacent vertices (i.e. 4->5, 5->3, 3->1, etc.), and it seemed to work, though I wasn't sure if that was correct. How do the points connect to each other?
Additionally, from the qvoronoi output (option 'FN'), I can get the vertices of each region, but there is no information about the connectivity between the vertices. I am wondering where this information is. Is it in the ridges output, or in a different qvoronoi output option?
The indices of the ridge do not seem to be in cyclic order. So, reconstructing back the polygon face might not be possible.
An alternate is to pass the output of gvoronoi of each cell to qconvex to construct the convex hull. This does not scale well, but might be okay if you have few cells you want to visualize or analyse.
For example, to get Voronoi cell of input site 5 of 30 input sites:
$ rbox 30 D3 | qvoronoi QV5 p | qconvex G
Try convex hull
Because Voronoi guarantees only convex polyhedra, there's a hacky way of finding this by finding a convex hull (in my case, scipy.spatial.ConvexHull()). The minimal convex hull surrounding your Voronoi region will be equivalent to what you want, and scipy.spatial even gives you further stuff for free
hull=scipy.spatial.ConvexHull(vertices)
volume=hull.volume
triangle_mesh_hull=vertices[hull.simplices] # shape is (n,3,3)
credit for the very short, elegant lines above goes to Jaime. If you want to do something to each triangular section of the mesh after this, you can access it like:
for triangle in triangle_mesh_hull:
do_stuff_to(triangle)
...
...
...
do_more_stuff_with(triangle)
...
...
...