function FlaecheDrachenviereck

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

clc;
close('all')
global ax
ax=[inf -inf inf -inf];
a=[11;0];
b=[-3;7];
n=[-a(2);a(1)]/norm(a);
h=n*n'*b;
A=[0;0];
drawPolygon(@plot,[A A+a+b A+a A+a+b-2*h A],'k','linewidth',1.5)
hold('on')

drawPolygon(@plot,[A+a+b A+a+b-2*h],'k','linewidth',0.25)
drawPolygon(@plot,[A A+a],'k','linewidth',0.25)
q=1;
na=q*[-a(2);a(1)]/norm(a);
drawPolygon(@plot,[A A+na],'--k','linewidth',0.25)
drawPolygon(@plot,[A+a A+a+na],'--k','linewidth',0.25)
drawPeak([A+na/2 A+a+na/2],[-a a],q/2,30*pi/180,'k');
drawPolygon(@plot,[A+na/2 A+a+na/2],'k','linewidth',0.25)

hold('off')
Schrift(A+a+b-0.5*h,'{\ite}/2','HorizontalAlignment','right','VerticalAlignment','middle');
Schrift(A+a+b-1.5*h,'{\ite}/2','HorizontalAlignment','right','VerticalAlignment','middle');
Schrift(A+a/2+na/2,'\itf','HorizontalAlignment','center','VerticalAlignment','bottom');
axis('equal')
axis(ax)
axis('off')
print('-depsc','FlaecheDrachenviereck');

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


function drawPeak(P,v,L,phi,varargin);
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);
  drawPolygon(@fill,[P(:,k) Q(:,k) R(:,k)],varargin{:})
end
