function h=Height(draw,XX,YY)

%Height  It calculates or draws the heigh of the ceiling at the given positions
%
% h=Height(draw,XX,YY)
%
% draw: defines the behavior of the function
%   if 0: calculate the values
%   otherwise: draw the height basic elements
% XX: x positions
% YY: y positions
% h: height at the given positions

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 8: Monte Carlo II
% Autores: Eva Besada-Portas, Sergey M. Plis


[lxm,lxM,lym,lyM]=MapLimits;

if draw %
    plot([9,9],[lym,lyM],'k');
    plot([11,11],[lym,lyM],'k');
    plot([14,14],[lym,lyM],'k');
    plot([16,16],[lym,lyM],'k');
    plot(40+15*cos(0:0.01:2*pi),30+15*sin(0:0.01:2*pi),'k');
    plot([lxm lxM lxM lxm lxm],[lym lym lyM lyM lym],'k');
    axis square;
else
    h=2*ones(size(XX));
    k=find(XX>9& XX<11);
    h(k)=h(k)-0.30;
    k=find(XX>14& XX<16);
    h(k)=h(k)-0.30;
    dist=(XX-40).^2+(YY-30).^2;
    k=find(dist<15^2);
    h(k)=h(k)+(15^2-dist(k))/200;
end