Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Terrain Modeling 1-Computer Sciences Applications-Project Report, Study Guides, Projects, Research of Applications of Computer Sciences

This project report is part of degree completion in computer science at Ambedkar University, Delhi. Its main points are: Terrain, Modeling, Fractional, Brownian, Motion, Generating, Techniques, Midpoint, Displacement, Fault, Formation

Typology: Study Guides, Projects, Research

2011/2012

Uploaded on 07/16/2012

sameer
sameer 🇮🇳

4.4

(59)

85 documents

1 / 19

Toggle sidebar

Related documents


Partial preview of the text

Download Terrain Modeling 1-Computer Sciences Applications-Project Report and more Study Guides, Projects, Research Applications of Computer Sciences in PDF only on Docsity! i Table of Contents Overview ............................................................................................................................. 1 1 Terrain Modeling ........................................................................................................ 2 1.1 Modeling Approaches ......................................................................................... 2 1.2 Mathematical Models of Natural Phenomena ..................................................... 2 1.2.1 Fractals ........................................................................................................ 2 1.2.2 Properties of Fractals .................................................................................. 3 1.3 Fractional Brownian Motion (fBm) .................................................................... 4 1.4 Origins of Fractal Terrain Models ...................................................................... 5 1.5 Limitations of Fractional Brownian Motion ....................................................... 5 1.6 Monofractals ....................................................................................................... 5 1.7 Multifractals ........................................................................................................ 6 2 Terrain Generation Techniques ................................................................................... 7 2.1 Midpoint Displacement ....................................................................................... 7 2.1.1 1-Dimesional Midpoint Displacement ........................................................ 7 2.1.2 2-Dimensional Midpoint Displacement (Diamond-Square Algorithm) ... 11 2.2 Fault Formation ................................................................................................. 13 3 References ................................................................................................................. 16 docsity.com ii List of Figures Figure 2-1 Midpoint Displacement in 1D when h=0.0, n=5, height range=100................. 9 Figure 2-2 Midpoint Displacement in 1D when h=1.0, n=5, height range=100................. 9 Figure 2-3 Wire frame image of a terrain generated using the Midpoint Displacement algorithm, number of subdivisions= 8 and the maximum height range= 500 .......... 12 Figure 2-4 The first step in fault formation algorithm [3] ................................................ 13 Figure 2-5 Terrain generated using fault formation, the number of faults=64 and height scale=20 .................................................................................................................... 15 docsity.com 2 1 Terrain Modeling This section describes the modeling approaches used for terrain generation. 1.1 Modeling Approaches There are two polar extremes in approaches to modelling: 1. ontogenetic modelling, 2. teleological modelling Ontogenetic modeling is visually driven that is "if it looks good, it is good". Teleological modeling is a more thorough approach of developing computational implementations of mathematical models taken from the scientific literature. The first approach emphasizes efficiency; the second veracity. In view of the fact that it is a computer graphics project I will be following the ontogenetic approach to modeling. Scientific veracity and mathematical proofs are beyond the scope of this project. [1] 1.2 Mathematical Models of Natural Phenomena Our world is visually complex. Reproducing this complexity in synthetic images is a major task in computer graphics. Fractals represent the natural phenomena in terms of equations that efficiently encapsulate lots of complexity found in nature. This encapsulation is usually in the form of recursive routines: a way that is exquisitely suited to the capabilities of the digital computer. 1.2.1 Fractals Although fractals can be used to model much of the complexity found in nature they are not the end-all for creating realistic synthetic images. Fractal geometry is mathematics, but it can be approached entirely heuristically: no understanding of the underlying formulas is required. A fractal can be defined as a geometrically complex object whose complexity arises through the repetition of a given form over a range of scales. docsity.com 3 1.2.2 Properties of Fractals Fractals can be thought of as complex shapes possessing dilation symmetry. Dilation symmetry is when an object is invariant under change of scale. Fractal complexity can be achieved simply by: repeating the same thing over and over, at different scales. Another property of fractals is that they have fractal dimensions. The familiar Euclidean dimensions are integer-valued: zero dimensions correspond to a point, one to a line, two to a plane, and three to space. Fractal dimension extends this concept to allow real- numbered values. Consider for example the fractal dimension 2.3, which lies between 2 and 3 dimensions, as the value of the fractal dimension rises from 2.0 to 3.0, the 2.0 dimensional plane becomes rougher and rougher, and more visually complex, until it densely occupies some volume of three-dimensional space. The 2 in 2.3, indicates the underlying Euclidean dimension of the fractal, in this case a plane. The “fractional” part, for example, the .3 in 2.3, is called the fractal increment. As this part varies from .0 to .999 . . . , the fractal literally goes from occupying only its underlying Euclidean dimension, a plane, to densely filling some part of the next higher dimension, such as space. The cause of this intermediate dimensionality is simply the repetition of some underlying shape, over a variety of different scales. This underlying shape is called the basis function. The basis function is usually a pseudo random noise function. For a noise function frequency is defined as 1/wavelength. Amplitude of a noise function is defined as the difference between the minimum and maximum values the function can have. Lacunarity is defined as the change in frequency. The amount by which we change the frequency, in each step of the iterative addition process is referred to as the lacunarity of the fractal. Lacunarity is a Latin word for “gap.” In this case, the gap is between successive frequencies in the fractal construction. Lacunarity is usually set at 2.0. Each successive noise function that is added is known as an octave. There is a well-defined relationship between the amount by which we scale size and the amount by which we scale the height or frequency versus amplitude. This relationship is what determines the fractal dimension of our result. Persistence is a single number that is used to specify the amplitude of each frequency and the relationship is expressed as: docsity.com 4 frequency = 2 i amplitude = persistence i It is not necessary for an object to have infinite detail to qualify as a fractal: as long as something displays self-similarity over some, albeit small, range of scale, it may qualify as “fractal.” There exists a size limit above which self-similarity ceases to manifest itself; this is called the upper crossover scale. Similarly, there is a smaller size limit below which self-similarity no longer is manifest; this is the lower crossover scale. All fractals in nature are band-limited i.e. they are fractal only over some limited range of scales. For example, Earth has many mountain ranges that are quite fractal but when seen from a distance in space the earth appears smoother than a glass marble. All fractals for computer graphics must also be bandlimited, for two reasons: First, spatial frequencies that are higher than half the pixel frequency (the screen width divided by resolution) may violate the Nyquist sampling limit and cause aliasing Second, it is a poor programming practice to use an infinite loop that would be required to construct non-band-limited fractals. 1.3 Fractional Brownian Motion (fBm) Fractional Brownian Motion is a random fractal function which resembles the skyline of a mountain range. This similarity between fBm and the skyline of mountain peaks was first observed by Benoit Mandelbrot. Pure fBm is by design homogeneous and isotropic. These two properties of pure fBm are in contrast with the properties of the real terrains, which are non homogeneous and an-isotropic. However it is possible to control the fBm to generate terrains which have the same properties as the real terrains. Two such fractal techniques called the monofractals and multifractals exist. fBm is characterized by its power spectrum, which shows exactly how amplitude relates to frequency. V(t)  f    A f r fH sin(2πr -f t f ) This is a Weierstrass-Mandelbrot function which describes the fractional brownian motion. Here A is a Gaussian random variable, r is the lacunarity, θ is a uniform random docsity.com 7 2 Terrain Generation Techniques 2.1 Midpoint Displacement Midpoint displacement as the name implies is a technique used for creating Fractal Mountains using a recursive subdivision scheme. The technique was developed by Fournier, Fussell, and Carpenter. In midpoint displacement we take a line segment along the x-axis and divide it into two equal halves. The mid-point is displaced along the y direction. The midpoint divides the line segment into two and each half is treated as a single line segment. In the next step the two halves are divided and their mid-points moved in the y direction. We repeat the process a number of times to achieve the desired effect. : xnew = (xi + xi+1)/2 ynew = (yi + yi+1)/2 + Rand*2 (-H) H is the roughness constant whose value can vary from 0.0 to 1.0 and R is a random number. If we set H=0.0 then 2 (-0.0) would give us 1 and the random number range would not be reduced at all, and if we set H=1.0 then 2 (-1.0) would result in 0.5 and the random number when multiplied with 0.5 will be halved. An extension of this algorithm is called the diamond-square algorithm.[9] 2.1.1 1-Dimesional Midpoint Displacement Midpoint Displacement in one dimension has been implemented using the technique explained above. I have created a function which divides the initial line segment and then calls itself in a recursive manner to divide each resulting line segment that is created. The number of times the recursion takes place is controlled by a variable whose initial value is set outside the function and every time the function is called the value of this variable is reduced. When the value of this variable becomes zero the display function is called which displays the perturbed line, which was initially a horizontal line.[9] docsity.com 8 2.1.1.1 Pseudo code In this section I present the pseudo coed for the function that actually calculates the midpoints and displaces them in the y direction and which controls how many times the function should be called. Here n is the parameter which controls the number of recursions and h is the roughness constant; the amount by which the random number range is reduce in every function call. Initialize n //number of subdivisions Initialize h // roughness constant Divide_Segment { while (n>0) { divide line segment raise the midpoint in y direction=rand () %random number range reduce random number range = (rand ()%random number range )*2 (-h) n=n-1 call Divide_Segment } display } As discussed in the previous section if we set H=0.0 the result generated is shown in Figure 2-1. Here the subdivisions are performed 5 times and the maximum height range is 200.This is a very jagged result because the height range (from 0 to the maximum height) is not reduced at all, meaning that totally random values are selected from the height range resulting in a jagged output. docsity.com 9 Figure 2-1 Midpoint Displacement in 1D when h=0.0, n=5, height range=100 Consider for example Figure 2-2 where H is set to 1.0. The number of subdivisions and the maximum height range are the same only the roughness constant has been changed from 0.0 to 1.0.Note that it is a comparatively smooth output which resembles the skyline of a mountain. In this case the height range is reduced by half i.e. (2 (-1.0) = 0.5) every time the function is called. Figure 2-2 Midpoint Displacement in 1D when h=1.0, n=5, height range=100 2.1.1.2 Results The results generated by using the midpoint displacement algorithm in one dimension have been compiled into Table 2-1. The length of the initial horizontal line segment is 200. The table shows the results corresponding to the number of subdivisions. The table shows how the roughness constant „H‟ effects the resulting displacements. docsity.com 12 Initialize rng // the maximum height range divide_terrain (3dpoint a, 3dpoint b, 3dpoint c, 3dpoint d, k, rng) { 3dpoint mp, ab, bc, cd, da if (k>0) { for (j=0;j<=2;j++) mp[j]=(a[j]+b[j]+c[j]+d[j])/4.0; //diamond step mp[1]+=rand()%rng; rng=rng*pow(2,h); // reduce height range ab=(a+b)/2 //square step bc=(b+c)/2 cd=(c+d)/2 da=(d+a)/2 divide_terrain (a, ab, mp, da, k-1, rng); divide_terrain (b, bc, mp, ab, k-1, rng); divide_terrain (bc, c, cd, mp, k-1, rng); divide_terrain (mp, cd, d, da, k-1, rng); } else display_diamond_square (a, b, c, d); } 2.1.2.2 Results Figure 2-3 Wire frame image of a terrain generated using the Midpoint Displacement algorithm, number of subdivisions= 8 and the maximum height range= 500 docsity.com 13 2.2 Fault Formation Fault Formation algorithm generates fractal data by repeatedly dividing the terrain with a faulting edge. A height difference along the fault edge is created by raising the terrain on one side of the fault edge and lowering it at the other side. Figure 2-4 shows the first step in fault formation. We begin by adding a random line to the height field and then adding a random height to any one of the two sides of the line. We evaluate only one side of the line and raise the height value of every point on that side of the line. This random height decreases linearly with every fault pass. Figure 2-4 The first step in fault formation algorithm [3] To raise the height value of every point on one side of the line, we loop through all of the height values for the entire height map. We define a vector that goes in the direction of the line, this vector is defined by Dirx1=randx2-randx1 Diry1=randy2-randy1 We define another vector from the initial random point (randx1, randy1) to the current point in the loop (x, z). Dirx2=x - randx1 Diry2=y - randy1 Then we take the cross product of the two vectors: (Dirx1, Diry1) x (Dirx2, Diry2) =iDirX2*iDirZ1 - iDirX1*iDirZ2 docsity.com 14 For all values of x and y for which the above cross product is greater than zero are assigned a random height which is calculated from the following formula. Height = (h_max+1)-(((h_max - h_min)*Current fault pass)/total number of faults) 2.2.1.1 Pseudo code divide_terrain (2Dpoint pt1, 2Dpoint pt2, k) { 2Dpoint dir1, dir2 k=Number_of_Faults h=h_max a[D][D]; while (k>0) { dir1=pt2-pt1 //direction vector along the fault edge for( i=0; i<D; i++ ) { for( j=0; j<D; j++ ) { dir2= (i-pt1[0], j-pt1[1]) //another vector from every x, y // point to the initial point pt1 Cross_Product=(dir1*dir2) if(Cross_Product >0) { a[i][j]+=h } } }// Completes one fault Edge h= (h_max+1)-(((h_max-h_min)*k)/Number_of_Faults) //reduce height k=k-1; pt1= (random, random)//choose two random points for the next Fault edge pt2= (random, random) } 2.2.1.2 Results Table 2-3 shows the height maps generated using the fault formation algorithm. A height map is a two dimensional image which defines the height for every vertex in the terrain. docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved