A Fractal Model of Mountains with Rivers
Total Page:16
File Type:pdf, Size:1020Kb
A Fractal Model of Mountains with Rivers Przemyslaw Prusinkiewicz and Mark Hammel Department of Computer Science University of Calgary Calgary, Alberta, Canada T2N 1N4 e-mail: [email protected] From Proceeding of Graphics Interface ’93, pages 174–180, May 1993 Held in Toronto, Ontario, 19-21 May 1993 A Fractal Model of Mountains with Rivers Przemyslaw Prusinkiewicz and Mark Hammel Department of Computer Science University of Calgary Calgary, Alberta, Canada T2N 1N4 e-mail addresses: [email protected], [email protected] x ABSTRACT C y y B A This paper addresses the long-standing problem of generating x x y fractal mountains with rivers, and presents a partial solution A B C that incorporates a squig-curve model of a river’s course into the midpoint-displacement model for mountains. The method Figure 1: A production for fractal mountain generation us- is based on the observation that both models can be expressed ing the midpoint displacement method. The initial altitudes by similar context-sensitive rewriting mechanisms. As a re- x ;x x B C A and of the vertices of a subdivided triangle,and the sult, a mountain landscape with a river can be generated using y ;y y B C displacement values A and , vary between instances a single integrated process. of production application. KEYWORDS: modeling of natural phenomena, terrain mod- els, midpoint displacement, squig curve, context-sensitive We begin with a review of the basic midpoint-displacement geometric rewriting. construction. A description of the squig-curve construction follows. The two constructions are then related as different INTRODUCTION facets of the same context-sensitive process of triangle subdi- In 1988, Mandelbrot pointed out “the most basic defect of past vision, and combined into a model of mountains with rivers. fractal forgeries of landscape” — the fact that each of them The paper is concluded by a list of topics open for further fails to include river networks [12, pages 243–260]. Since research. then, Kelley, Malin and Nielson [5] overcame this limitation by generating fractal terrain around a predefined drainage MIDPOINT-DISPLACEMENT METHOD REVISITED system. Pursuing an alternative approach, Musgrave, Kolb, In the simplest version of the midpoint-displacement method, and Mace [11] created river channels by simulating water an initial horizontal triangle is subdivided into four smaller erosion in fractal mountains. Both methods require separate triangles, and the newly created vertices are displaced ver- processes to define the mountain and the river system. A dif- tically by random values. A similar process is repeated for ferent technique was introduced by Bardeen, whose program each of the smaller triangles, then for each of their descen- Panorama [1] combines mountain and river generation into a dants, until a given recursion limit is reached. Smith [14] single process. The details of his algorithm have not yet been presented midpoint displacement as a rewriting process gov- published. erned by the class of productions depicted in Figure 1. This characterization related fractal mountain generation to for- In this paper we introduce a method that — like Bardeen’s mal language theory, and raised a question regarding the — creates the mountain and the river system simultaneously. nature of the rewriting process in hand: Is it context-free or Specifically, we combine the midpoint-displacement method context-sensitive? Smith wrote: “In formal language theory, for mountain generation given by Fournier, Fussell, and Car- as Loren Carpenter has pointed out to me, the problem with penter [3] with the squig-curve model of a non-branching his language is that it is context-free. Information internal to river originated by Mandelbrot [7, 8] (see also [9, Chapter an original database triangle is never passed to neighboring 24]). Our method employs a context-sensitive rewriting sys- triangles.” Although this view has been supported in the liter- tem operating on geometric objects. Theoretical interest in ature [10], [12, page 244], it disregards a form of information such systems has been spawned by Smith [14], but few exam- transfer that does take place between neighboring triangles. ples have been investigated to date. Consequently, a part of As shown in Figure 2, we cannot apply the production of Q our paper is devoted to the discussion of the context-sensitive Figure 1 independently to triangles P and sharing a com- l aspects of the constructions under consideration. mon edge l , since the displacement of the midpoint of must P a Q 1 3 yP yQ 2 lQ lP Figure 2: The midpoint-displacement method is context- b 1 3 3 2 2 1 Q sensitive. After the subdivision of triangles P and , the l l Q midpoints of the coinciding edges P and are displaced y = y Q by vectors of equal lengths, P . In practical imple- 2 1 3 l l l Q mentations, lines P and collapse to a single edge shared 3 2 1 Q between triangles P and . 1 2 3 1 2 3 a predecessors c d 1 3 3 2 2 1 successors 1 3 1 3 3 2 3 2 2 2 1 1 1 3 1 3 1 3 3 2 3 2 3 2 b predecessors 2 2 2 1 1 1 1 3 1 3 1 3 1 3 3 2 3 2 3 2 3 2 2 2 2 2 1 1 1 1 Figure 4: Information transfer in the midpoint-displacement successors method. Production (a) has six instances (b). The subdivision pattern of the bottom left triangle determines the subdivision Figure 3: Information transfer in context-sensitive parallel patterns for all remaining triangles, as shown here for the grammars (a) and in the midpoint-displacement method (b). third level of recursion (c, d). Continuous arrows represent the flow of information from the parent object to its replacement. Dashed arrows represent the flow of contextual information. ther illustrated in Figure 4. The productions (a) are assumed to raise midpoints of the subdivided edges by 1, 2, and 3 units, Q be the same for both P and [3]. Thus, the production counting counterclockwise. Distinguishing between possible instance applied to triangle P depends on that applied to tri- orientations of the subdivided edges, we obtain six instances angle Q, and vice versa. This implies information transfer of production (a), as shown in (b). During the construction of Q between P and , although its nature is different from that a mountain, the production instance applied, say, to the bot- usually considered in formal language theory (specifically, tom left triangle determines production instances appropriate in the theory of L-systems, which deals with parallel rewrit- for subdividing all other triangles (c, d). Thus, information is ing [6]). Traditionally, the set of applicable productions is passed between the bottom left triangle and all other triangles constrained by the neighbors of the strict predecessor (the in the mesh. symbol being replaced). On the other hand, in midpoint dis- placement each production is constrained by the successors Note that Figures 4 (c) and (d) can also be viewed as tilings of the productions applied concurrently to the neighboring using tiles with labeled edges. Coinciding edges must have triangles (Figure 3). Nonetheless, in both cases the outcome the same label. A square-grid counterpart of such tilings was of a production depends on its neighbors, and in this sense proposed and studied by Wang [15, 16] (see also [4, Chapter both production types are context-sensitive. 11]), who showed that the operation of any Turing machine can be simulated using a set of appropriately labeled tiles. The information transfer associated with context-sensitive Clearly, a context-sensitive information-passing mechanism productions used in the midpoint-displacementmethod is fur- is needed to achieve this computational power. displacement (x , y ) (x , y ) A A B B random number table Edges: entry, exit, neutral. x Figure 6: Productions for generating a squig curve. Before hashing production application, the predecessor and the successor function may be translated, rotated, reflected, and scaled. Arrows scaling indicate the direction of the curve (river flow). Vertical bars factor separate alternative production successors. Figure 5: Deterministic calculation of a psuedorandom midpoint-displacement value. by the curve. Each production subdivides the predecessor triangle into four smaller triangles, satisfying the following constraints: The context-sensitive nature of the midpoint-displacement method may be hidden by programming techniques used to The entry edge of the predecessor is subdivided into an implement it. For example, Fournier et al. wrote [3]: “An entry edge and a neutral edge; obvious requirement is that the same random displacements must be generated on each boundary, which can be accom- The exit edge of the predecessor is subdivided into an plished by tying the seeds of the random number generator exit edge and a neutral edge; to identifiers of points on the boundary, making certain that The neutral edge of the predecessor is subdivided into the same identifiers are assigned to the corresponding points two neutral edges; in the representation of each polygon’s boundary.” A deter- ministic variant of this technique, suggested by Smith [14], is Each pair of coinciding edges inside the subdivided tri- illustrated in Figure 5. When an edge is subdivided, the coor- angle consists either of an entry and an exit edge, or of dinates of its endpoints determine, via a hashing function, an two neutral edges. index into a prestored table of random numbers that represent possible displacement values. Thus, if the displacement of Figure 6 shows a set of four productions satisfying these cri- the midpoint of edge l in Figure 2 is calculated separately teria. The squig curve construction begins with a triangle Q l for both triangles P and that share , the returned values that has one entry and one exit edge.