How can I connect all Delaunay triangle to voronoi? - delaunay

I have a list of all triangle sharing an edge. How can I draw a voronoi diagram? I loop over the Delaunay triangles and compare it to vertex 1 = vertex 2 and vertex 2 = vertex 1, I. e. if there are the same edges. It also checks when vertex 1 = vertex 1 and vertex 2 = vertex 2. In the equation both side is a different triangle. It's the same loop from the boywer watson algorithm.

When two triangles are adjacent in the Delaunay triangulation, draw a line segment between the circumcenters of these triangles.
There is an easy to remember rule for the duality between Delaunay triangulations and Voronoi diagrams: The dimensions of the dual elements always sum up to the dimension of space. For example in 2D:
Delaunay <-> Voronoi
Triangle (2) + Point (0) = 2
Segment (1) + Segment (1) = 2
Point (0) + Cell (2) = 2
...similar in 3D.

Related

How to compute inner angle of two segments in polygon triangulation

Context
I have to implement a polygon triangulation algorithm for a school assignment. I chose to follow the algorithm described in the book "Computational Geometry: Algorithms and Applications".
The input is a polygon stored as a doubly-connected edge list. The first step is to partition the polygon into monotone pieces. In order to do so, it's necessary to perform a line sweep and process each vertex according to its type. According to the authors, the vertex types are described as follows:
We distinguish five types of vertices in P—see Figure 3.3. Four of these
types are turn vertices: start vertices, split vertices, end vertices, and merge
vertices. They are defined as follows. A vertex v is a start vertex if its two
neighbors lie below it and the interior angle at v is less than π; if the interior
angle is greater than π then v is a split vertex. (If both neighbors lie below
v, then the interior angle cannot be exactly π.) A vertex is an end vertex if
its two neighbors lie above it and the interior angle at v is less than π; if the
interior angle is greater than π then v is a merge vertex. The vertices that
are not turn vertices are regular vertices. Thus a regular vertex has one of its
neighbors above it, and the other neighbor below it.
The problem
I can't figure out how to differentiate start vertices from split vertices, or end vertices from merge vertices. How can I do it?
Additional info
My data struct for the DCEL is something like this
class HalfEdge {
HalfEdge *previous, *next, *twin;
Point *to, *from;
};
Maybe if you keep track of a counter clock-wise orientation of the polygon's boundary (i.e. keep the edges directed), you could distinguish the two. Say the consecutive vertices are v[i-1], v[i], v[i+1] and v[i-1] and v[i+1] are below v[i]. Then form the 2D vectors v[i]-v[i-1] and v[i+1]-v[i]. After that, calculate the determinant det( v[i]-v[i-1] , v[i+1]-v[i] ). If the determinant is positive, then the vertex is start. If the determinant is negative, the vertex is split.

How to create a non-intersecting polygon in 3D containing n given points on a sphere?

I have the coordinates of n points on a sphere and I know they are all coplanar. How can I find the edges of the polygon which has the vertex the n given points?
OK, your problem is weird ordering.
Project all points onto any convenient plane - the simplest approach is using OXY, OXZ or OYZ plane (choose one that is not perpendicular to your plane) - in this case you just use (P[i].X. P[i].Y, 0) for P[i] point and sort projected 2D points by angle against the first point - it works because points on sphere arc form convex polygon. Then use this ordering as polygon vertex indexes.

Calculate points on surface of 3d model

I have a 3d model (from Blender) with vertices, vertices normals (normalized) and faces (triangles). I need to calculate additional vertices and their normals. Other words, I need algorithm to calculate center vertex for triangle from three vertices and three vertices normals.
For example, in picture we have A, B, C vertices. How to calculate D vertex and it's normal?
Or, even better, point E (center of one of the sides).
Could anybody help me?
If you want point D lie exactly on plane based on ABC then I suggest you to use barycentric coordinates. Point D is intersection of medians and it is (1/3, 1/3, 1/3) in barycentric coordinates, or D = 1/3A + 1/3B + 1/3C, E would be (0,1/2,1/2). The normal ND should be calculated in the same way as D, ND = 1/3NA + 1/3NB + 1/3NC.
You didn't state the reason why do you need to calculate D and E. I suppose you want to get more triangles in the mesh, thus better level of detail. In this case PN-triangles should be used

Do order of coordinates affect the drawing of polygon in Java

I am asking if there is any particular order that i need to input my set of coordinates for the drawing of polygon using Graphics2D class in Java.
For example, do values of my coordinates(X,Y) need to be arranged in descending/ascending order for both X and Y arrays of coordinates?
Or another example is if i wish to draw a polygon and i have 4 sets of points, topleft, topright, bottomright and bottomleft and i simply input them in this order to drawPolygon method in Java to get a drawn polygon with corners corresponding to all this 4 points.
Or i can just arrange my coordinates in any random order?
Thanks in advance.
To understand polygon filling in general you have to understand edge direction, winding order and the selected polygon fill rule.
Edge direction is determined by the order that vertices have been declared. For example ...
Polygon poly= new Polygon();
poly.addPoint(10, 10);
poly.addPoint(100, 10);
poly.addPoint(100, 100);
poly.addPoint(10, 100);
Polygons are drawn by joining adjacent vertices (from an ordered list of vertices) to form edges. The last vertex in the list is also joining the first (as if the list were circular). The first edge in the polygon above is constructed from the first two vertices - Point(10,10) and Point(100,10).
Whenever polygons self-intersect or overlap, to understand how the polygons will be drawn, you need a knowledge of both winding order and the applied polygon filling rule. When polygons overlap, polygon sub-regions are created - discrete regions that are enclosed by edges. The winding order of these sub-regions and the applied polygon filling rule determine whether these sub-regions are filled or not.
(source: angusj.com)
The winding number for any given polygon sub-region can be derived by:
set the winding count to zero
from a point (P1) that's within a given sub-region, draw an imaginary horizontal line to another point that's outside the polygon or polygons (P2)
while traversing this line from P1 to P2, for each polygon edge that crosses this imaginary line - if it's heading up then increment the winding count, otherwise decrement the winding count.
According to the Java Graphics2D documentation, fillPolygon only uses the even-odd fill rule where only odd numbered sub-regions are filled.
(source: angusj.com)
The polygon is drawn from each point to the following point.
So the two points of an edge have to be neighbors in the list of points you submit to DrawPolygon.
If you want to draw a polygon between the points A, B, C and D, you will need to submit these points in the order
A,B,C,D or
D,A,B,C or
C,D,A,B or
B,C,D,A or
D,C,B,A or
A,D,C,B or
B,A,D,C or
C,B,A,D or
All other combinations of A,B,C and D will produce a polygon with the same points but different edges
This is the polygon you get if you use one of the above orders
A------B
| |
| |
| |
D------C
This is the polygon you get if you use for example A,B,D,C
A------B
\ /
\ /
*
/ \
/ \
D-----C

For a cubic, given 8 coordinates of vertices, how to get coordinate pair of 12 edges?

I thought about this quesion for a while, and googling "edge" or "vertices" does not return anything useful.
Yes it's very simple for cubic, but not so easy for arbitrary shape in 3D. E.g. a concave body. You might find some diagonal lines but it's not the edge.
This general term for this question is called Convex Hull
It's widely used in GIS
https://gis.stackexchange.com/questions/1200/concave-hull-definition-algorithms-and-practical-solutions
And the most famous algorithm is done by Graham Scan from ACM
GRAHAM_SCAN(Q)
Find p0 in Q with minimum y-coordinate (and minimum x-coordinate if there are ties).
Sorted the remaining points of Q (that is, Q ? {p0}) by polar angle in counterclockwise order with respect to p0.
TOP [S] = 0 ? Lines 3-6 initialize the stack to contain, from bottom to top, first three points.
PUSH (p0, S)
PUSH (p1, S)
PUSH (p2, S)
for i = 3 to m ? Perform test for each point p3, ..., pm.
do while the angle between NEXT_TO_TOP[S], TOP[S], and pi makes a nonleft turn ? remove if not a vertex
do POP(S)
PUSH (S, pi)
return S
http://en.wikipedia.org/wiki/Graham_scan
http://www.personal.kent.edu/~rmuhamma/Compgeometry/MyCG/ConvexHull/GrahamScan/grahamScan.htm
Fun fact: convex OR concave hull has a patent:
https://stackoverflow.com/a/2241263/41948

Resources