function EuklSphAbst

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

clc;
close('all')
deg=pi/180;
beta=35*deg;
O=[0;0];
A=[cos(pi/2+beta);sin(pi/2+beta)];
B=[cos(pi/2-beta);sin(pi/2-beta)];
global ax
ax=[A(1) B(1) 0 1.02];
drawPolygon(@plot,[A O B],'k')
hold('on')
drawPolygon(@plot,[O [0;1]],'k')
drawPolygon(@plot,[A B],'k','linewidth',1.5)
Kreisbogen(B,O,A,0,'k','linewidth',1.5)
Kreisbogen(0.2*B,O,0.2*A,0,'k')
Schrift([0;0.08],'\beta \beta','HorizontalAlignment','center','VerticalAlignment','bottom')
Schrift(A,'\itA','HorizontalAlignment','right','VerticalAlignment','middle')
Schrift(B,'\itB','HorizontalAlignment','left','VerticalAlignment','middle')
Schrift([0;0.98],'{\itd}_{\itS}({\itA},{\itB})','HorizontalAlignment','center','VerticalAlignment','bottom')
Schrift([0;cos(beta)],'{\itd}({\itA},{\itB})','HorizontalAlignment','center','VerticalAlignment','bottom')
Schrift([-sin(beta)/2;cos(beta)],'{\itd}({\itA},{\itB})_{ }/_{ }2',...
  'FontSize',30,'HorizontalAlignment','center','VerticalAlignment','top')
Schrift([sin(beta)/2;cos(beta)],'{\itd}({\itA},{\itB})_{ }/_{ }2',...
  'FontSize',30,'HorizontalAlignment','center','VerticalAlignment','top')
Schrift(A/2,'\itR',...
  'FontSize',30,'rotation',beta/deg-90,'HorizontalAlignment','center','VerticalAlignment','top')
Schrift(B/2,'\itR',...
  'FontSize',30,'rotation',90-beta/deg,'HorizontalAlignment','center','VerticalAlignment','top')
hold('off')
axis('off')
axis('equal')
axis(ax)
print('-depsc','EuklSphAbst')

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',36,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{:});

