Calculation of volume with the use of "NTF" method Izračun volumnov z uporabo "NTF" metode MlLIVOJ VULIC1, Anes DURGUTOVIC2 'Faculty of Natural Science and Engineering, University of Ljubljana, Aškerčeva cesta 12, SI-1000 Ljubljana, Slovenia; E-mail: milivoj.vulic@ntf.uni-lj.si 2Oikos d.o.o., Jarška cesta 30, SI-1230 Ljubljana, Slovenia; E-mail: anes.durgutovic@oikos.si Received: October 02, 2006 Accepted: October 20, 2006 Abstract: The development of computer science, GPS, up to date instruments and methods for measurement has enabled fast collection and handling of data. Nowadays, we can come across many different programs which, on the basis of input data, give results of the shape volume. However, these programs function on the basis of the black box and we can therefore, only make assumptions about their accuracy. Due to the fact that the results, which we get with the use of programs, differ among themselves, we have made "NTF" method of volume calculation. In this article we wish to present the mentioned method and the mathematical background of the volume calculation. Izvleček: Razvoj računalništva, GPS-a, sodobnih merskih instrumentov ter metod merjenja je omogočil zelo hitro pridobivanje in obdelavo podatkov. Danes lahko srečamo celo vrsto računalniških programov, ki nam na podlagi vhodnih podatkov podajo rezultat o prostornini neke mase. Toda le ti delajo na principu črne skrinjice in o njihovi natančnosti lahko samo ugibamo. Ker se rezultati, ki jih programi podajajo med seboj razlikujejo smo zasnovali metodo izračuna volumnov »NTF«, katero vam v tem prispevku želimo predstaviti. V prispevku vam želimo prikazati, kakšna je zamisel tega načina in njegovo matematično ozadje. Key words: volume calculation, Delauney triangulation, MS Excel, UDF Ključne besede: izračun volumnov, Delaunayeva triangulacija, MS Excel , UDF Introduction The development of computer science, GPS, up to date instruments and methods for measurement has enabled fast collection and handling of data. Nowadays, we can come across many different programs which on the basis of input data give results of the shape volume. This implies to fast calculation of area or volume calculation. The way of life is also based on the fact that it is important to acquire results in the short period of time. Due to that people nowadays use the software programs when working on calculation of volume. However, these programs function on the basis of the black box and we can therefore, only make assumptions about their accuracy. However, the results we get with the use of programs (programs, which enable the calculation of the volume) vary among 222 Vulic,M., Durgutoyic, A. themselves. In order to find out why these particular programs give various results we would be bound to the background of their function. Because this would be difficult we have decided to prepare the method of volume calculation in the range of our own capacities. In this way we have made "NTF" method of volume calculation. The basis of this method and the mathematical background of the volume calculation are shown in the article calculation of the volume with the use of "NTF" method. With the consideration of mathematical principles we have used positive characteristics of program tools MS Excel and with the help of Microsoft Visual Basic for Applications1, we have prepared User Defined Functions (UDF), which enable us to define the volume of shape in MS Excel program. The principal of volume calculation, based on Delauney triangulation, what is also the characteristic of already mentioned programs. Calculation of the volume with THE USE OF "NTF" METHOD Volume of shape (dump, embankment...) can be calculated in different ways. The selection of the way, among others, depends on the shape as well as on the accuracy which we wish to reach at the volume calculation. For the less complicated geometrical shapes, where it is possible to combine geometrical shape from regular geometrical shape, we can use way of determining the volume by abstracting volume of individual regular geometrical shape. For the volume calculation in practice the most usual principals are: • Volume calculation from profile, • Volume calculation from the already carried out triangulation net. Triangle net is mostly used for modeling of the surface of the area. That is because the triangle net matches measured points on the field. The already carried out Delauney triangulation of the shape to which we wish to calculate volume with the use of "NTF" method. Delaunay triangulation is the process of calculating a triangle net that tries, among the given points, to find equilateral triangles. The idea of the "NTF" method If we have a series of data about the coordinate points of a particular shape, we can with the help of a suitable program from the series of data carry out Delaunay triangulation. The shape to which we wish to calculate volume, we separate with certain contour line into two parts. We get upper and down part of that shape. Visual Basic for Applications (VBA) is the variety of program language Microsoft Visual Basic for programming of macro in applications for Windows operation systems Figure 1. The separation of the shape into down and upper part Slika 1. Razdelitev telesa na spodnji in zgornji del To this shape with the upper and down surface we determine a certain reference high and on that reference high we create horizontal surface. In a mathematical way we can determine reference high anywhere in ending. In a numerical way it is best to choose it there where the partial amount of individual volume is the lowest, or rather where the sum of high differences of the upper and down surface equals zero. We can achieve this by determine the reference high in the centre of gravity, according to one dimension (high). But if for the reference high take minimal high from the set of the lowest location points we will not make a big mistake. Due to the pretentiousness of determination of the centre of gravity it is recommend-able to take minimal high from the set of the lowest location points. With the help of the horizontal surface on the chosen reference high and data about the edges which form triangles of the carried out Delaunay triangulation, we can solve the problem of the volume of the limited space by volume calculation of the final number of vertical triangle prism. After we have carried out Delaney triangulation of the upper and down surface and chosen the reference high, we can on the basis of already mentioned finding calculate: • Volume between upper surface of the shape and the surface on the reference high (volume of the upper part of the shape), • Volume between down surface of the shape and the surface on the reference high (volume of the down part of the shape). The difference between volumes gives us a final volume of geometrical shape. Mathematical basis of the "NTF" method After the carried out Delaney triangulation of the surface we have the limited surface space to which we wish to calculate volume with the help of the horizontal surface on the chosen reference high and data about the edges which form triangles of the carried out Delaney triangulation, we separated on vertical triangle prism. With this we separated, the volume of limited surface space, by volume calculation of the final number of vertical triangle prism. We are, from the mathematical point of view, interested in the volume calculation of one vertical triangle prism. An example of such prism is given in the picture below. Figure 2. Example of triangle prism Slika 2. Primer tristrane prizme Coordinates of the given points of basis on the defined surface are: (Xui>yunZref+h) --(Xu2>yu2>ZKf+hd --(x«i>yu2>zKf+th) Are gained by projecting of points u}, u2 and u3 on horizontal surface on the reference high. We get the coordinates of reference points that are: = (wi>v) = (*2 > y2 ' Zref) = (x3,y2,Zr¥) (3) Because of the easier volume calculation of the mentioned triangle prism, we separate this prism into three different geometrical shapes. We get two tetrahedron and one regular prism as it is shown in the picture below: (1). Figure 3. Separate prism Slika 3. Razdeljena prizma Coordinate points of the second basis, or rather, points on horizontal surface on the reference high which is given by equitation: Z = Z, ref (2), Volume calculation of separated triangle prism Because of the better understanding and more simple way of calculation, we name the shapes after colors which are presented in Figure 3. That we get: • Green prism (GP), • Blue tetrahedron (BT), • Red tetrahedron (RT). Volume of the green prism, which is formed by edges r,, r2, r3, u,, dt, d, we can write with a following formula: VGP=BASEnorm-\ (4), At which the "BASEnorm" area of normal section, therefore triangles r,, r2, r3or triangles u,, d, d3 Formula for area of normal section is: *«i y,\ 1 *„2 y«2 1 BASE = X"3 y"2 1 norm 2! (5). Volume of blue tetrahedron which is formed by edges u, d2, d3, u2 we can write with: v —ha w {BT)uld2d1u2 norm * ^ (6) It is known that the volume of pyramid dose not change if the top of this pyramid moves on the surface which is paralleled to basis. Due to this the volume of red tetrahedron which is formed by edges u, u2, d3, u3 will not change if it will parallel with the surface u, d,, u3 point u2 move into point d2. That is: v -v — B/W ' (,87>IK2rf3U3 _ ' (BT^d^d^ ~ "^^norm ' ^ (7) If we calculate the volume of green prism, red tetrahedron and blue tetrahedron, we get final volume of mentioned triangle prism which is presented on the Figure 2. We write this as: V = VBT + VRT + VGP = BASE ■ ^ + BASE ■ ^zh + BASEnorm ■ hzK JSi Kl \jr norm ^ norm ^ norm ^ V = BASE_h^k^ If we now also take into consideration for the surface of normal section "BASE ", norm ' equation 5 we get: Table 1. Coordinate points of edge Tabela 1. Koordinatne točke oglišč obeh trikotnikov v = ul y« i i i ul y «3 \+h2+hi 3! (9). With the purpose of simplifying the calculation on the basis of conclusion of the above described mathematical way of volume calculation in the program MS Excel we have prepare "UDF" for volume calculation with "NTF" method. Representation of the correct volume calculation We carry out volume calculation with the use of NTF method in MS Excel program. For this we have, on the basis of the above mentioned findings, prepared "UDF" which enable realization of volume calculation with the use of MS Excel program. With the purpose of examining the correctness of the volume calculation with the use of already mentioned tools. We have carried out tests in the computer program MS Excel. To this purpose we have used the prism model which is shown in the Figure 2. Data about Zref Volume UP Volume DOWN Accurate volume AV=Vd-Vd 90 4000 7000 3000 45 -500 2500 3000 40 -1000 2000 3000 35 -1500 1500 3000 20 -3000 -0 3000 15 -3500 -500 3000 10 ^000 -1000 3000 5 -4500 -1500 3000 0 -5000 -2000 3000 coordinate points of edges of both basis are presented in the Table 1. With the use of UDF »point3VolumeW« in the program MS Excel we have calculated the volume of the given prism for various reference highs. For the use of the calculation we have chosen several different values of reference high, because we wished to check if the mentioned UDF will give the same value of the volume regardless the value of reference high. Results which we have gained are presented in the Table 2. As seen from the table above, with the use of UDF »point3VolumeW«, we get the same final value of the volume regardless the chosen reference high value. Due to this we can hide the reference high. In order to avoid eventual machine error it is recommended to take reference high as the smallest high from the set of given points. Table 2. Chosen reference high value Tabela 2. Prikaz izbranih vrednosti referenčnih višine in prikaz končnega rezultata zref Volume UP Volume DOWN Accurate volume av=vd-vd 90 4000 7000 3000 45 -500 2500 3000 40 -1000 2000 3000 35 -1500 1500 3000 20 -3000 -0 3000 15 -3500 -500 3000 10 -4000 -1000 3000 5 -4500 -1500 3000 0 -5000 -2000 3000 In order to check whether written UDF »point3VolumeW« in the program MS Excel gives a correct result we have separated the presented prisms shape into three regular geometrical shapes in Figure 1. We calculate the volume of mentioned geometrical shapes with the use of standard mathematical forms. v = vrt + vmt+vzp = 333,333 + 666,666 + 2000 = 3000 (10) From the above written result we can see that we get the same value of the volume of the prism shape as well as by the use of the above mentioned UDF »point3VolumeW«. Conclusion On the basis of the above mentioned finds we see that the final value of the volume will not change on the dependence of reference point value. No matter the value of the reference high we always get the same result. UDF also gives us the right value of the shape which we have proved in the example above. We can with the adding up the calculated volume of the individual vertical prisms which form the volume surface limited space we calculate the final shape volume. The way we carry out calculation on a practical example and the way of using UDF for the volume calculation with the use of NTF method will be given in the next articles. References [1] J. N. Bronštejn-K. A. Semendjajev, Matematični priročnik, Tehniška založba Slovenije v Ljubljani, 1978. 683 str. [2] Joseph O'rourke, Computational geometry in C. Cabbridge univerity press,1997 350 str. [3] VuLic, Milivoj, »User Defined Function«, februar 2005 [4] VuLic, Milivoj, Matematične osnove določanja pros- tornin tristranih prizem (interna predavanja), marec 2005 [5] VuLic, Milivoj, Osnove Delaunay-eve triangulacije in Voronoi diagramov (interna predavanja), februar 2005.