![]() |
||||
|
||||
Fractal Terrain Generation Fractals are seen in many areas of nature, such as geographical terrain. It is fairly easy for a computer-generated fractals to look identical to real life terrains. This is an algorithm to create it.
First, start with a line with two endpoints:
Now find the midpoint of this line, and
displace that point upwards or downwards by a random amount in a fixed
range, called H. Then we may find something like this:
Now we have two line segments.
Recursively run the same algorithm on each line segment. We may get
something like this:
And so on and so on. Thus, this
algorithm for 8 iterations, for four different lines may produce:
Here are four possible terrains.
However, they look very different. This is because I left out the
most crucial step of the algorithm, which is for each iteration, we reduce
H. This means that in each iteration, we reduce the range of the
iteration. Varying the amount of reduction will result in different
terrains, such as above. The chart for the colors are:
Thus, we see that the higher the value for
H, the less jagged than with a lower value of H. The value that the
range is calculated is by taking a random number between 0.0 and 1.0, and
then multiplying it by H * 2^(-H). Thus, if you have a H with the
value of 1.0, then your displacement range will be halved each time.
Having a low H value means your range will not be reduced, and the terrain
will be jaggy.
Here are four examples of four lines at sixteen iterations. Notice how the more iterations, the more jagged the picture is:
|
||||
|
|