function circle(P,r,s,col)
%usage circle(P,r,s,col) 
%plot a circle around P (row vector) with radius r
%the colorstring has the same syntax as in the plot command 
%the string s is put on the circle

global PHIVAR;

%initialize global variable
if isempty(PHIVAR) PHIVAR=0; end;

%number of points for plotting
N=100;
%angles for plotting
theta=linspace(0,2*pi,N)';
Q=repmat(P,N,1)+r*[cos(theta),sin(theta)];
plot(Q(:,1),Q(:,2),col);
%get random angle
x=P(1)+cos(PHIVAR)*r;
y=P(2)+sin(PHIVAR)*r;
text(x,y,s);
%increase writing angle
PHIVAR=PHIVAR+23/180*pi;
%adjust axes if necessary
Lc=max(max(abs(Q)));
L=max(abs(axis));
if Lc>L
  axis([-Lc,Lc,-Lc,Lc]);
end;
