detri2 tutorial: generating triangulations of point sets · • in this tutorial, we’re going to...
TRANSCRIPT
Detri2 Tutorial: Generating Triangulations
of Point Sets
Hang Si
General Remarks• In this tutorial, we’re going to learn how to use Detri2 to
create (arbitrary) triangulations, Delaunay triangulations of 2d point sets, and to visualise the algorithms.
• learn how to create an input point set within the free program Gmsh.
• learn some basic Detri2 command line options to generate these triangulations.
• learn how to visualise the triangulations in the free program Paraview.
• I assume you have already compiled Detri2 and got the executable file, like, detri2.exe in Windows, or other detri2 binary files for Linux, or Mac OSX.
• I assume you have installed both Gmsh and Paraview in your system. They are both available in the CourseSoftware directory.
• For saving output files (there will be many output files by detri2 for visualising algorithms) I also created a ``demo” directory in my Desktop.
Install these two programs
create a new directory on your Desktop
The Input file of Detri2
• Detri2 reads a .node file (an ASCII text file) which stores a list of 2d points. The .node file format is exactly the same as Triangle’s .node file format.
• Below is an example input file of a set of 7 points in 2d.
A ‘#’ means comments
number of points2 dimension
point index
x, y coordinates
An example input file: r7.node
• Alternatively, Detri2 can read the .geo file format of Gmsh which stores a list of points and straight line segments.
• Below is an example of a .geo file.
• It is convenient to use Gmsh’s GUI to create and save a .geo file.
A point
An example input p8.geo file of Gmsh
Use Gmsh to create an input file for Detri2
• Below figures show how to use Gmsh’s GUI to create and save a .geo file.
first click ``Geometry”
click ``Point” to create points
• Below figures show how to use Gmsh’s GUI to create and save a .geo file.
save a file (must with .geo)
once finish creating points, choose ``save as…”
Use Detri2 to generate a triangulation from Gmsh’s .geo file
• Let the new created .geo file and the executable detri2.exe be in the same directory, like ``demo”.
• We need a command line shell to run detri2
type ``cmd” to open a command line shell
• Within the ``demo” directory, run the command: ``detri2.exe -Gu -Gd point.geo”
• The above command will generate the Delaunay triangulation of the point set.
• With the option (-Gu) detri2 will save the final triangulation into a file which can be visualised by Paraview.
• With the option (-Gd) detri2 will save all the intermediate triangulations into files which can be visualised by Paraview. This helps to visualise the algorithm.
type this command
first go to the ``demo” directory
• Within the ``demo” directory, run the command: ``detri2.exe -Gu -Gd point.geo”
• The above command will generate the Delaunay triangulation of the point set.
• With the option (-Gu) detri2 will save the final triangulation into a file which can be visualised by Paraview.
• With the option (-Gd) detri2 will save all the intermediate triangulations into files which can be visualised by Paraview. This helps to visualise the algorithm.
files can be visualised by Paraview
Use Paraview to visualise the triangulations
• Start Paraview
start ``Paraview”
• Open files
click
• Select ``AVS UCD Binary/ASCII Files”
select
• Click the ``Apply” button.
click
• It shows the first triangulation (which is only a triangle). Click the ``play” button.
click
• Once it stops, it shows the last Delaunay triangulation. done!
More command line options
• Before you try a different option, it is better to delete all the generated .inp files for Paraview. Otherwise you may get too many files in your computer.
• Use the sweep-line algorithm (-Ss#,#) to generate an initial triangulation, non-Delaunay (-L), where #,# defines a 2d vector which is the normal of the sweep-line.
• Command: detri2 -Ss0.5,0.5 -L -Gu points.geo
TRIANGULATIONS OF POINT SETS IN R2 9
Algorithm: LineSweep(S, s)Input: A set S of n points in R2, s is the normal of sweep line;Output: A triangulation T of S;1 sort the points in S into a sequence L := {p1, . . .pn
} along s;2 initialize T with only one triangle {p1,p2,p3};3 for i = 4 to n do4 let Q be the set of all visible edges of p
i
;5 create new triangles to T by each edge in Q and p
i
;6 endfor
Figure 10. The sweep line triangulation algorithm.
Figure 11. Construction a triangulation by a line-sweep algorithm.
newly created triangles is less than 2n � 4. Thus this line sweep algorithm constructs atriangulation in O(n log n) time.
This section introduces the Delaunay triangulation of any point set in the plane. Itis introduced by the Russian mathematician Boris Nikolaevich Delone (1890–1980) in1934 [3]. It is a triangulation with many nice properties. There are many ways to defineDelaunay triangulations. We first introduce them as duals of Voronoi diagrams, thenintroduce other equivalent definitions while showing their properties.
2. Delaunay Triangulations
2.1. Voronoi diagrams. Voronoi diagrams are named after the Russian and Ukrainianmathematician Georgy Feodosevich Voronoy (1868–1908) in 1907 [15]. Voronoi diagramsarise in nature in various situations. They are the one of the most fundamental datastructures in computational geometry.
Voronoi diagram divides the plane according to the nearest-neighbour rule: Each pointis associated with region of the plane closet to it.
Let S be a set of n points (called sites) in R2. the Voronoi region of a site p 2 S isthe set of points x 2 R2 that are as close to p as to any other site in S, that is
Vp
= {x 2 R2 | kx � pk kx � qk, 8q 2 S},
where k · k means Euclidean distance.
• Use the Lawson’s flip algorithm (-l) to transform a non-Delaunay triangulation (points.1.ele) into the Delaunay triangulation.
• Command: detri2 -l -Gu points.1.eleTRIANGULATIONS OF POINT SETS IN R2 17
Figure 22. Lawson’s flip algorithm takes an arbitrary triangulation(left) as input and returns the Delaunay triangulation (right).
Figure 23. The lifted view of the Lawson’s flip algorithm which trans-forms a non-convex surface (left) in 3d into a convex one (right).
2.4.4. Termination and running time. Flipping ab to cd is likely gluing a tetrahedrona0b0c0d0 from below to a0b0c0 and a0b0d0.
The algorithm can be understood as gluing a sequence of tetrahedra. Once we gluea0b0c0d0 we cannot glue another tetrahedron right below a0b0. In other words, once weflip ab we cannot introduce ab again by some other flip. This implies that the Lawson’sedge-flip algorithm will eventually terminate when all locally non-Delaunay edges areflipped. By the Delaunay lemma, the triangulation is Delaunay. This also implies thereare at most as many flips as there are edges connecting n points, namely
�n
2
�. Each flip
takes constant time, hence the total running time is O(n2).
2.4.5. The MaxMin angle property. We illustrate an optimal property of the Delaunaytriangulation.
Theorem 2.3. Among all triangulation of a finite point set S ⇢ R2, the Delaunay
triangulation maximises the minimum angle.
Proof. A flip substitute two new triangles for two old triangles. It therefore changes sixof the angles, see Figure 24. The six old angles are:
↵1, �1, �1 + �2, ↵2, �2, �1 + �2,
• Use the Lawson’s flip algorithm (-l) to transform a non-Delaunay triangulation (points.1.ele) into the Delaunay triangulation, and save the lifting triangulation (-GL) as well, and save all the intermediate triangulations (-Gd).
• Command: detri2 -l -Gu -GL -Gd points.1.ele
TRIANGULATIONS OF POINT SETS IN R2 17
Figure 22. Lawson’s flip algorithm takes an arbitrary triangulation(left) as input and returns the Delaunay triangulation (right).
Figure 23. The lifted view of the Lawson’s flip algorithm which trans-forms a non-convex surface (left) in 3d into a convex one (right).
2.4.4. Termination and running time. Flipping ab to cd is likely gluing a tetrahedrona0b0c0d0 from below to a0b0c0 and a0b0d0.
The algorithm can be understood as gluing a sequence of tetrahedra. Once we gluea0b0c0d0 we cannot glue another tetrahedron right below a0b0. In other words, once weflip ab we cannot introduce ab again by some other flip. This implies that the Lawson’sedge-flip algorithm will eventually terminate when all locally non-Delaunay edges areflipped. By the Delaunay lemma, the triangulation is Delaunay. This also implies thereare at most as many flips as there are edges connecting n points, namely
�n
2
�. Each flip
takes constant time, hence the total running time is O(n2).
2.4.5. The MaxMin angle property. We illustrate an optimal property of the Delaunaytriangulation.
Theorem 2.3. Among all triangulation of a finite point set S ⇢ R2, the Delaunay
triangulation maximises the minimum angle.
Proof. A flip substitute two new triangles for two old triangles. It therefore changes sixof the angles, see Figure 24. The six old angles are:
↵1, �1, �1 + �2, ↵2, �2, �1 + �2,