Click here to Skip to main content
15,878,852 members
Articles / Programming Languages / C++
Article

Delaunay's TIN - Triangulated Irregular Network

Rate me:
Please Sign up or sign in to vote.
4.36/5 (28 votes)
18 Apr 20043 min read 183.2K   15.6K   66   34
Delaunay's TIN - Triangulated Irregular Network

Sample Image - maximum width is 600 pixels

Introduction

This program generates Triangulated Irregular Network, or TIN from scattered points on two-dimensional plane based on Delaunay's triangulation. This data structure allows data to be displayed as three-dimensional surface, or to be used for terrain analysis including contouring and visibility mapping.

Using the code

The source codes, if successfully compiled will generate a simple console program which only takes two arguments. The first argument should be a name of the points file. Points are read from this simple text file with a list of X-Y, or X-Y-Z coordinates separated by comma. Although z coordinates are not used in the calculation, data with altitude information can be used for perspective viewing in demo program, TriNET. Below is example of input file for data shown in the figure:

200,790
370,760
60,670
360,890
280,620
30,880
230,960

or,

200,790,100
370,760,110
60,670,115
360,890,92
280,620,125
30,880,95
230,960,110

The list of triangles is saved to triangle file. Triangle file is generated in the same directory as the input file with extension "tri". The output file will look like this. In this example, six triangles are generated and in the resulting "tri" file, sequential numbers of generated triangle vertices are listed as below:

1,6,7
1,3,6
2,7,4
1,2,5
1,7,2
1,5,3

For example, the first triangle(A) consists of the first, sixth and seventh vertices in the input file.
Image 2 Image 3
Two point files, Davis.nod and test32.nod are included in this distribution file as examples.

Notes on algorithm

The second argument to this program decides whether the convex hull is used or not. If this is set to N, or no second argument is given, in order to generate triangles beyond the area boundary, a set of pseudo points are generated around the extents of the points.
Contrarily, if 'Y' is given to this parameter, the convex hull is generated and is used as a boundary of the input area. Convex hull (in 2D) is a smallest convex polygon, which include all input points. As shown in the example below, as compared to the network in the left, all parts in the convex hull are triangulated in the right figure, but it tends to create triangles of irregular shape(blue triangles in the right figure), which do not fulfill the condition that the largest inner angles of all generated triangles must be minimized.

Image 4 Image 5

Demo Program

I added Windows program, TriNET to interactively run and display the results of triangulation. To construct TIN from a set of scattered points, select from a menu, "Terrain" -> "Construct TIN" or "Construct TIN - Convex Hull" and select points file from dialog. Check the menu item, "Terrain" -> "Display Monitor" to observe the process of triangulation real time. This has no effect in the result of calculation except that it makes it significantly slower. It is just for fun! Input points and generated triangles can be displayed in TriNET. If the points have z coordinates, generated TIN can be used for perspective viewing. Select each function from "Draw" menu.
Image 6 Image 7
Image 8 Image 9
In three-dimensional display, use left and right arrows to rotate horizontally, and up and down key to change the depression angle. F1 and F2 keys widen and narrow the field of view.

TriNET requires GDI+ library. The runtime module can be obtained at the website of the Microsoft. Copy gdiplus.dll to windows system directory. TriNET also requires MFC71.dll and msvcr71.dll.

References

This program uses Delaunay's triangulation method. There are a number of documents published or available on the net about this algorithm. I used a book written by John C. Davis, "Statistics and Data Analysis in Geology, Third Edition", John Wiley and Sons(2002), which included very plane but thorough description on this algorithm.

History

  • First upload, 14/4/2004 - Only hoping people don't have to vomit after reading my English.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCompete Source code Pin
Member 134676595-Nov-17 23:22
Member 134676595-Nov-17 23:22 
QuestionTriNet source code Pin
Member 132932624-Jul-17 17:06
Member 132932624-Jul-17 17:06 
Questionmọi người có thể tìm hiểu giúp mình về ưu điểm và nhược điểm cảu mạng lưới delaunay đc k ạ... mình cảm ơn nhiều ạ Pin
Member 1241339023-Mar-16 20:47
Member 1241339023-Mar-16 20:47 
QuestionThank's Pin
Puppy Boo20-Mar-15 3:20
Puppy Boo20-Mar-15 3:20 
QuestionSome questions about 3D Pin
Member 1081660213-May-14 16:37
Member 1081660213-May-14 16:37 
QuestionSome questions Pin
dickobe29-Mar-14 2:23
dickobe29-Mar-14 2:23 
QuestionHi Pin
opium_2100210018-Nov-11 6:45
opium_2100210018-Nov-11 6:45 
GeneralNeed volume calculation code Pin
Parvathaneni Mamatha5-Jul-11 1:40
professionalParvathaneni Mamatha5-Jul-11 1:40 
GeneralRe: Need volume calculation code Pin
sajmon446-Jan-13 6:14
sajmon446-Jan-13 6:14 
Generalnew member Pin
lily_white28-Mar-11 4:14
lily_white28-Mar-11 4:14 
GeneralTriangle_net Question Pin
meast110-Oct-10 4:24
meast110-Oct-10 4:24 
Generalsimilar data set, but different results Pin
jin_chen589-Jan-10 20:34
jin_chen589-Jan-10 20:34 
hi there,

i got a problem with a similar data but different results. for example, if the data set is:
370,760
60,670
280,620
300,300
230,160
it generates 4 triangles as 3,1,2; 2,1,0; 1,3,4; 3,2,0.

however, if the data is slightly changed as:
370,760
60,670
280,420 (note: only this 420 data is changed)
300,300
230,160
the triangles becomes 3 as 2,1,0; 1,4,3; 3,2,0

there is something wrong with the convex hull triangle calculation, but i just could not figure out where. any advices are highly appreciated and many thanks in advance.

james chen
Generallicense Pin
dan ilie17-Sep-09 18:54
dan ilie17-Sep-09 18:54 
Generalquestion about using delaunay trangulation to construct 3D terrain Pin
dlzhanglei22-May-09 1:14
dlzhanglei22-May-09 1:14 
QuestionSome question about the three-dimensional object! [modified] Pin
tonio ann16-Feb-09 2:50
tonio ann16-Feb-09 2:50 
Generalabout the 3D! Pin
farid_colombia24-Oct-08 11:26
farid_colombia24-Oct-08 11:26 
GeneralCube Pin
henry110328-Apr-08 21:39
henry110328-Apr-08 21:39 
Generalgood Pin
Marco Magi4-Jun-07 23:32
Marco Magi4-Jun-07 23:32 
GeneralHigh Complexity Pin
sagido8-Dec-06 6:59
sagido8-Dec-06 6:59 
Questionremove points with identical X and Y coordinates Pin
kastoraki3-Aug-06 2:48
kastoraki3-Aug-06 2:48 
Generalvery good code, but i have a question Pin
kastoraki23-Jul-06 23:27
kastoraki23-Jul-06 23:27 
GeneralVery good Pin
tasv23-Feb-06 5:15
tasv23-Feb-06 5:15 
GeneralOut of memory Pin
zindines27-Oct-05 10:56
zindines27-Oct-05 10:56 
General3D surface code Pin
Jacques Lemaire26-Apr-05 4:50
Jacques Lemaire26-Apr-05 4:50 
GeneralRe: 3D surface code Pin
farid_colombia26-Oct-08 6:49
farid_colombia26-Oct-08 6:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.