cube = [];

for( northings=-50:5:50 )
  for( eastings=-50:5:50)
    for( z = 0:-5:-100 )
      cube( end+1,: ) = [eastings     northings z];
    end
  end
end

triangle=[];

offset1 = 600;

for( z=0:-5:-100)
  for( i=1:21 )
    x(i) = 5*(i-1) - 50;
    if( x(i) <= 0 )
      y(i) = x(i) + 50;
    elseif( x(i) > 0 )
      y(i) = -x(i) + 50;
    end
    %
    % Make the edge:
    triangle(end+1,:) = [x(i)+offset1 y(i) z];
    % Now fill in:
    for( yy=0:5:floor(y(i)) )
      triangle(end+1,:) = [x(i)+offset1 yy z];
    end
  end
end

offset2 = -600;

ellipse=[];

major=50;
minor=30;
for( z=0:-5:-100)
  for( x=-50:5:50 )
    %
    % Make the edge:
    ymax = round( minor*sqrt(1 - (x/major)^2));
    ymin = round(-minor*sqrt(1 - (x/major)^2));
    ellipse(end+1,:) = [x+offset2 ymax z];
    ellipse(end+1,:) = [x+offset2 ymin z];
    % Now fill in:
    for( yy=ymin:5:ymax )
      ellipse(end+1,:) = [x+offset2 yy z];
    end
  end
end

shapes = [cube; triangle; ellipse];

csvwrite('shapes.csv',shapes);
