180 C Small World Model Implementation
return Surface[x][y];
}
float del2xy(int x, int y) //Laplacian
{
return ( (h(x+1,y)+h(x-1,y)+
h(x,y+1)+h(x,y-1)-
(float)4*h(x,y) )/(deltax)*(deltax) );
}
float sw(int x, int y)
//Small world links for surface point at (x,y)
{
float growth = 0;
int shad_len = 10;
//Shadowing length, or lambda_0
//Heights are linked if separated by
//a distance less than shad_len
for(int k=-shad_len; k<=shad_len; k++)
{
for(int l=-shad_len; l<=shad_len; l++)
{
if( sqrt(k*k+l*l)<= shad_len)
{
growth += -(h(x+k,y+l)-h(x,y));
//Link strength is negative
}
}
}
return growth;
}
float noise()
{
//Box-Muller transform to generate Gaussian random
//variables with mean zero and variance one
float x1, x2, k, y;
do {
x1 = 2 * rand()/((float)RAND_MAX) - 1;
x2 = 2 * rand()/((float)RAND_MAX) - 1;