function Pos=MapLight(draw)

%MapLight   It calculates the positions of the lights
%
% Pos=MapLight(draw)
% draw: if 0 only calculate the positions of the lights, otherwise also draw them.
% Pos: a matrix with as many rows as lights. 
%      Pos(k,1)=x position of light k
%      Pos(k,2)=y position of light k
%

% 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;

y=(lym+2.5):5:(lyM-2.5);
x=(lym+2.5):5:(lyM-2.5);
[xx,yy]=meshgrid(x,y);

Pos=[xx(:),yy(:)];
%dist=(Pos(:,1)-40).^2+(Pos(:,2)-30).^2;
%k=find(dist<15^2);
k=find(Pos(:,1)>25 & Pos(:,1)<55 & Pos(:,2)>15 & Pos(:,2)<45);
Pos(k,:)=[];

if draw
    plot(Pos(:,1),Pos(:,2),'co','MarkerFaceColor','c');
end
