function Radiant

% http://geometrie.hs-nb.de/MATLAB-Programme/Radiant.m   Bearbeitungsstand: 17.1.2005
% (C) Martin Nitschke, nitschke@hs-nb.de

clc;
close('all')
global ax
ax=[inf -inf inf -inf];
deg=pi/180;
alpha=10*deg;
beta=alpha+1;
O=[0;0];
A=[cos(alpha);sin(alpha)];
B=[cos(beta);sin(beta)];
drawPolygon(@plot,[A O B],'k','linewidth',2.0)
hold('on')
Kreisbogen(A,O,B,0,'k','linewidth',5.0)
Kreisbogen(B,O,A,0,'k')
Kreisbogen(0.45*A,O,0.45*B,0,'k')
Schrift(A/2,'1 m','rotation',alpha/deg,'HorizontalAlignment','center','VerticalAlignment','top')
Schrift(O,'    1 rad','rotation',(alpha+beta)/(2*deg),'HorizontalAlignment','left','VerticalAlignment','middle')
Schrift([cos((alpha+beta)/2);sin((alpha+beta)/2)],'1 m',...
  'rotation',(alpha+beta)/(2*deg)-90,'HorizontalAlignment','center','VerticalAlignment','top')
hold('off')
hold('off')
axis('off')
axis('equal')
axis([0 1 0 1])
print('-depsc','Radiant')

function drawPolygon(draw,P,varargin);
global ax
feval(draw,P(1,:),P(2,:),varargin{:})
if min(P(1,:))<ax(1)
  ax(1)=min(P(1,:));
end
if max(P(1,:))>ax(2)
  ax(2)=max(P(1,:));
end
if min(P(2,:))<ax(3)
  ax(3)=min(P(2,:));
end
if max(P(2,:))>ax(4)
  ax(4)=max(P(2,:));
end

function Schrift(P,txt,varargin)
text(P(1),P(2),txt,'FontName','TimesNewRoman','FontSize',50,varargin{:});

function Kreisbogen(A,M,B,offset,varargin)
deg=pi/180;
[t1,r1]=cart2pol(A(1)-M(1),A(2)-M(2));
[t2,r2]=cart2pol(B(1)-M(1),B(2)-M(2));
if abs(r1-r2)>sqrt(eps)
  error('Kreisbogen: A und B liegen nicht auf einem Kreis mit Mittelpunkt M')
end
r=(r1+r2)/2;
t1=t1-offset;
t2=t2+offset;
if t2<t1
  t2=t2+2*pi;
end
t=linspace(t1,t2,round((t2-t1)/deg));
drawPolygon(@plot,repmat(M,size(t))+r*[cos(t);sin(t)],varargin{:});

