## Fractal Mountains

*(GSB Semi-Cascade)*

Back to the main applet index page

*(Source code)*

### Creating Mountains the Fractal Way

This is a demonstration of how graphical figures that look like mountains can be created by using fractals.The technique involves applying "midpoint displacement" recursively to a starting grid of four rectangles. Each succeeding iteration is derived by displacing each midpoint of each side of each rectangle by an random amount. The set of 4 rectangles start out flat, and with each succeeding generation become more irregular in shape, simulating the rugged terrain of a mountain.

I also apply a limit to the amount by which a point can be displaced downward, creating a level surface that often surrounds the mountains that looks like a body of water surrounding them. I copied this idea from an implementation of fractal mountains that I saw in a magazine a bunch of years ago (have to see if I can find the reference to that !).

The grid that's being used to create the mountains is represented as a collection of rectangle objects, which are composed of edge objects, which in turn are composed of vertex objects. Adjacent rectangle objects share common edge and vertex objects. This is essentially an approach that's similar to what's used in solid modeling to represent objects in 3 dimensional space. As far as I know, the approach that I've used here is unique; the few algorithms that I've looked at for creating fractals have simply kept the coordinates of the grid points in a two dimensional array.

For each iteration in the generation of the fractal mountains, I create a new set of rectangles from the old set, then redraw using the new set and discard the old set. This is great because I don't have to juggle any old data around to accomodate the new, larger grid. But it really slams Java garbage collection ! Hence the numbers that I display about total and free memory...watch them as the generation progresses; you'll see free memory decrease and them suddenly increase again: that's Java VM garbage collection at work ! If the Java VM in your browser works like the one in mine, you won't see any perceptible delay in the progress of the iterations: Java garbage collection appears to be very efficient, introducing no human-perceptible delay in execution.

The way that I turn the grid up "on end", so that it looks like you're looking at it from a viewpoint in 3 dimensional space, is kind of a "cheat". Instead of doing a full 3 dimensional view transform, I just raise the Y coordinate of each vertex by the amount of the Z coordinate to give the effect that the figure has some height (see the FEdge.draw() method for more details about how this works). This was just an applet that I wrote "for fun", so I wanted to keep the code simple !

But taking this simpler approach to generating the three dimensional effect also saves computing time and resources. Generating a full three dimensional rendering of the fractal image would involve many more, and more expensive, floating point calculations. There was a short paper written by James Blinn in 1988, called "The Ancient Chinese Art of Chi-Ting" ("cheating"), where he proposes that, "literal simulation is not really necessary to make adequate pictures. All that is necessary is that the errors be confined to situations which are not visually apparent." For many computing applications, accuracy is important, but for the case of creating cool looking graphics, some corners can be cut. So the technique I apply here is very much in the spirit of Chi-Ting ! 8^)

The use of fractals to generate objects for computer graphics was first introduced (or at least popularized ?) by Loren Carpenter at Siggraph '80 in Seattle. He later went on to work at LucasFilm, and then Pixar.

Semi-interesting trivia: 1980 was also the year that Mt. St. Helens erupted (radically altering the shape of one mountain forever !).

### Bibliography

Loren C. Carpenter, Boeing Computer Services, Seattle, Washington"Computer Rendering of Fractal Curves and Surfaces"

Siggraph 80, Seattle, Washington

*
The landmark paper on use of fractals to generate mountains and other
figures for computer graphics. It did not appear in the main proceedings
of Siggraph '80, but was handed out separately at the conference.
*

### Web Resources

Tekla S. Perry"And the Oscar Goes To..."

IEEE Spectrum, Vol 38, Number 4, April, 2001

*
Includes the story behind Loren Carpenter's work with fractal mountain
generation.
*

A (Spotty) History and Who's Who of Computer Graphics

*A timeline of major events in computer graphics history.
*

James F. Blinn

"The Ancient Chinese Art of Chi-Ting"

Jet Propulsion Laboratory, Pasadena, California, 1/20/88

*
A quote from the abstract of the paper: "...literal simulation is not really
necessary to make adequate pictures. All that is necessary is that the
errors be confined to situations which are not visually apparent."
*

Back to my Applets page.