% 
%		ROCKIES
%
% 	This cryptic matlab script generates a structured but random spatial 
% 	environment of size NxN.  The user inputs the following:
%			N - number of grid points in both x,y directions
%			H - fractal dimension (the bigger this is the smoother the landscape)
%
N=64;
H=1.;
%N=np;
randn('seed',0);
A=zeros(N);
B=zeros(N);
m=N/2+1;
p=(H+1)/2;
[I,J]=meshgrid([-N/2+1:N/2], [-N/2+1:N/2]);
phases=2*pi*rand(N);
amp=(I.^2+J.^2).^(-p);
amp(N/2,N/2)=0;
As=amp.*exp(i*phases);

A=ifft2(As/N^2);
B=abs(A);
B=B/max(max(B));
surf(B), colormap(jet), shading interp
%title(['Power Spectral Density = 1 / f ^',num2str(p)])
%title(['Log(PS) = - ',num2str(p),' k'])
view(-37.5,60)