function Drehung2D

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

clc;
close('all')
deg=pi/180;
h=0.05;

[T,R]=meshgrid([0:5:360]*deg,linspace(0,sqrt(2),50));
[X,Y]=pol2cart(T,R);
plot(X,Y,X',Y','color',0.75*[1 1 1])
hold('on')
[m,n]=size(X);
nNull=1;
plot(X(:,nNull),Y(:,nNull),'k','linewidth',2.0)
m0=round(0.4*m);
n0=round(0.15*n);
n1=round(0.35*n);
Spitze([X(m0,n0);Y(m0,n0)],[X(m0,n0);Y(m0,n0)],h,45*deg);
Spitze([X(m0,n1);Y(m0,n1)],[X(m0,n1);Y(m0,n1)],h,45*deg);
Schrift([X(m0,n0);Y(m0,n0)],'\it\bfv','HorizontalAlignment','left','VerticalAlignment','bottom')
Schrift([X(m0,n1);Y(m0,n1)],'\it\bfw','HorizontalAlignment','right','VerticalAlignment','bottom')
plot(X(1:m0,n0),Y(1:m0,n0),'k')
plot(X(1:m0,n1),Y(1:m0,n1),'k')
plot(X(5,round(nNull):n0),Y(5,round(nNull):n0),'k')
Spitze([X(5,n0);Y(5,n0)],[-Y(5,n0);X(5,n0)],h/2,60*deg);
plot(X(6,n0:n1),Y(6,n0:n1),'k')
Spitze([X(6,n1);Y(6,n1)],[-Y(8,n1);X(8,n1)],h/2,60*deg);
plot(X(9,1:n1),Y(9,1:n1),'k')
Spitze([X(9,n1);Y(9,n1)],[-Y(11,n1);X(11,n1)],h/2,60*deg);
hold('off')
axis('equal')
axis([-0.5 0.5 -0.1 0.6])
axis('off')
Schrift([X(m0,n0);Y(m0,n0)]*0.5,' \itr','rotation',atan2(Y(m0,n0),X(m0,n0))/deg,...
  'HorizontalAlignment','left','VerticalAlignment','bottom')
Schrift([0;0],'   \itt','HorizontalAlignment','left','VerticalAlignment','bottom')
Schrift([X(7,round((n0+n1)/2));Y(7,round((n0+n1)/2))],'\alpha',...
  'HorizontalAlignment','center','VerticalAlignment','top')
Schrift([X(10,round((n0+n1)/2));Y(10,round((n0+n1)/2))],'\alpha+\itt',...
  'HorizontalAlignment','center','VerticalAlignment','top')
alpha=atan2(Y(m,nNull),X(m,nNull));
print('-depsc','Drehung2D');

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 Spitze(P,v,L,phi);
if nargin<=2
  L=1;
end
if nargin<=3
  phi=7.5*pi/180;
end
ta=tan(phi/2);
v=L*v./repmat(sqrt(dot(v,v)),size(P,1),1);
n=[-v(2,:);v(1,:)];
Q=P-v+ta*n;
R=P-v-ta*n;
for k=1:size(P,2);
  fill([P(1,k) Q(1,k) R(1,k)],[P(2,k) Q(2,k) R(2,k)],'k')
end
