This is a pretty silly waste of time and computational power, but I wanted to try doing this for a very long time: I finally got around to making some “fractal” landscapes.

The idea is that you if you generate a lot of gaussian bumps with randomly distributed parameters and add them all together, you will get the surface that looks like some natural landscape – a mountain, perhaps or an island, and then by playing around with the parameters of the distribution you can make your landscape look more or less rugged.

So, I started with a plain, added some bumps, and got this:

This doesn’t look very natural, does it? But then I added several more layers of smaller bumps, and created The Jelly Mountain:

Jelly Mountain looks pretty realistic, especially if you are willing to look past the hideousness of the color scheme. When I got slightly better at choosing parameters, I created The Candy Archipelago:

This has no theoretical importance whatsoever, but it’s still fun making something life-like out of equations and matrices.

Here’s some of my code for the curious and the masochistic:

restart;

with(LinearAlgebra): with(plots): with(Statistics):

N:=10000; disp:=1.5; S:=200; s:=S/2;

M:=matrix(S, S); for i from 1 to S do for j from 1 to S do M[i, j]:=0; od; od;

f:=(x, y, d, h)->h*exp(-(x^2+y^2)/d^2);

for i from 1 to N do xx:=evalf(Sample(RandomVariable(Uniform(-1, 1)), 1)[1], 3): yy:=evalf(Sample(RandomVariable(Uniform(-1, 1)), 1)[1], 3):

d:=evalf(Sample(RandomVariable(Normal(0, 1/300)),1)[1], 3):

evalf(i/N*100, 3);

for j from max(1, round(xx*100+s-disp*abs(d)*100)) to min(S, round(xx*100+s+disp*abs(d)*100)) do for k from max(1, round(yy*100+s-disp*abs(d)*100)) to min(S, round(yy*100+s+disp*abs(d)*100)) do

M[j, k]:=M[j, k]+evalf(f((j-s)/100-xx, (k-s)/100-yy, d, d), 3):

od; od; od:

matrixplot(M, style=surface, lightmodel=light2);

### Like this:

Like Loading...

*Related*