C++ program that constructs Delaunay triangulation and/or Voronoi diagram of a set of points. Built as a final project in the NYUAD Data Structures class in spring 2014.
The program can be run through terminal:
./run <num <delaunay voronoi>>
- The
num
argument determines the number of points added to the input file; the default value is20
. - The
delaunay
argument determines whether the Delaunay triangulation should be shown; the default istrue
. - The
voronoi
argument determines whether the Voronoi diagram should be shown; the default istrue
.
This produces an image file named output.png
with the resulting diagram.
If changes were made to the source files, the program has to be rebuilt first:
./build
To produce a specific number of random points in the accepted format:
g++ randinput.cpp -o randinput
./randinput <num>
- The
num
argument determines the number of points produced; the default value is20
.
To produce the Delaunay triangulation and/or Voronoi diagram based on a list of points:
g++ delaunay.cpp -o delaunay
./delaunay <input output <delaunay voronoi>>
- The
input
argument determines the address of the input file; the default isinput.txt
. - The
output
argument determines the address of the output file; the default isoutput.txt
. - The
delaunay
argument determines whether the Delaunay triangulation should be shown; the default istrue
. - The
voronoi
argument determines whether the Voronoi diagram should be shown; the default istrue
.
This produces an output.txt
file with instructions for gnuplot
program to draw the diagram.
If one does not wish to use the provided randinput
executable to produce input values, these can be input manually. The formatting is as follows:
x y
- The
x
andy
values are separated by\t
(tab).
The output file contains information for the gnuplot
program (/usr/local/bin/gnuplot
) to draw the diagram. It can be edited; however, next run of the delaunay
executable will overwrite any changes. For the changes to be permanent, they have to be made directly in the source code of delaunay.cpp
.
To ensure that the diagram will be drawn through gnuplot
, the first line of the output file has to be:
#!/usr/local/bin/gnuplot
Additionally, for the file to be drawn, it must be made executable. To ensure you have correct permissions, use:
chmod +x output.txt