| ★ APPLICATIONS ★ CREATION GRAPHIQUE ★ FRACTAL LANDSCAPE GENERATOR (AMSTRAD COMPUTER USER) ★ |
Fractal Landscape Generator (ACU 89/11)![]() | Fractal Landscape Generator (ACU 89/12)![]() | Fractal Landscape Generator (ACU 90/01)![]() | Fractal Landscape Generator (ACU 90/04) |
Learning to landscape Dean Cracknell delivers the final batch of his three part fractal bonanza. Having produced two programs that calculate the fractal landscape data, we now turn our attention to how the data is to be displayed. The original program used isometric projection to produce a 3D image, but this lacked perspective and did not allow us to see the landscape from different viewing positions. By using these listings you will be able to move around the landscape, and even look underneath. Although the projection uses machine code, the program still takes a couple of minutes to plot, so “flying around the landscape” is the phrase I was trying to avoid here. Perspective and 3D Projection: The machine code in Program 1 pretends that the CPC monitor screen is a window through which you are looking at the fractal landscape. It does this by projecting the landscape onto that window. To illustrate this, look out of a nearby window at the scene on the other side. Sunlight, reflected off the scenery, passes through the glass and enters your eye. Here lenses and light sensitive cells pass the image on to the brain where the most powerful image processing program ever written takes over and we ‘see' the image. If you draw the scene on the glass just as you see it, then this is what the CPC is trying to create on the monitor screen. To achieve this we need to know exactly what the image on the glass would look like. Figure (i) illustrates this: the triangle formed between the viewer, the top of the object and the horizontal has the same proportions as the triangle formed by the viewer and the image on the glass, but a different size. This means that if we divide one of the sides of the larger triangle by one of its other sides, the resulting number will be the same as the same ratio produced by the smaller triangle, or to put it more simply: Height on glass / Distance to glass = Height of object / Distance to object By quickly re-arranging this little equation, it is possible to calculate the height that the object will have on the glass as long as we know all the other numbers, which we do: Hglass = Dglass x Hobject / Dobject This simplified form lacks polish, such as scaling and an offset for the height of the viewer above the ground (his elevation), fully expanded the formula becomes: Hglass = Hscale x Dglass x Elevation-Hobject — / Dobject Normally, the distance from the viewer to the glass will be fixed, so this can be incorporated into the ‘Hscale' constant. Having considered the projection of the height of the object, the width is treated in the same way and produces a similar equation: Xglass = Xscale x Dglass x Xposition-Xobject / Dobject As these two equations are similar, they can be combined into a general purpose equation that can be used for both. The RSX command |PROJECT handles this equation for both the X and H projections. The X and H values come directly from the Fractal data, all the other values are held as variables in the program and can be changed at will. There are limitations to this kind of projection, in that you cannot project the image when the distance from the viewer to the object (Dobject) is zero, as you will get a “Divide by zero” error. In the real, real world this problem is solved by projecting the image into a curved surface, the back of your eye, and then using the brain to compute the true image. The machine code loader of program 1 loads-up the second half of the final machine code, adding a further 15 RSX's to the existing 12. Save and run this program, which will poke the code into memory and save it. The second listing, Program 2, should be typed in as seen, without changing the line numbers and saved as “part-2”. Now you should have a complete version of the full-blown Fractal Landscape Generator, when you run the program, the first landscape will be calculated and displayed as a counter map as before, but now the image display will contain a landscape of sea
ACU |
| ![]() |
|