function g = genhsph(r)
%
% genhsph: generate a 2D hemi-spherical surface of radius r
% On input:
%     r: radius of sphere
% On output:
%     g: 2*r+5 by 2*r+5 array with sphere elevations
% Call:
%     g = genhsph(r)
%

g = zeros(2*r+5,2*r+5);
mid = r+3;
for y = 1:2*r+5
  for x = 1:2*r+5
    if sqrt((x-mid)^2+(y-mid)^2)<=r
      g(x,y) = sqrt(r*r - (x-mid)^2 - (y-mid)^2);
    end
  end
end
