function ParDra

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

clc;
close('all')
global ax
deg=pi/180;
phi=[0:360]*deg;
ax=[inf -inf inf -inf];
A=[0;0]; c=[50;0]; b=[10;23]; B=A+c; C=A+b;
hold('on');

D=Parallelogramm(A,B,C); v=D-A;     A(1)=B(1)+1.2*c(1);  B=A+c; C=A+b;
D=Parallelogramm(B,C,A); v=[v D-A]; A(1)=B(1)+0.3*c(1);  B=A+c; C=A+b;
D=Parallelogramm(C,A,B); v=[v D-A]; A=[0;-2*b(2)];  B=A+c; C=A+b;
D=Drachenviereck(A,B,C); v=[v D-A]; A(1)=B(1)+0.3*c(1);  B=A+c; C=A+b;
D=Drachenviereck(B,C,A); v=[v D-A]; A(1)=B(1)+D(1)-A(1); B=A+c; C=A+b;
D=Drachenviereck(C,A,B);

hold('off')
axis('equal')
axis(ax)
axis('off')
print('-deps','ParDra-Lsg');

function D=ParallelogrammK(A,B,C)
D=B+C-A;

function D=Parallelogramm(A,B,C)
D=ParallelogrammK(A,B,C);
Polygon([A B D C A],'k','linewidth',1.5);
Polygon([B C],'k','linewidth',0.25);
Polygon([A B C],'xk','MarkerSize',10);

function D=DrachenviereckK(A,B,C)
c=B-A;
d=[-c(2);c(1)]/norm(c);
D=C-2*d*d'*(C-A);

function D=Drachenviereck(A,B,C)
D=DrachenviereckK(A,B,C);
Polygon([A D B C A],'k','linewidth',1.5);
Polygon([A B],'k','linewidth',0.25);
Polygon([C D],'k','linewidth',0.25);
Polygon([A B C],'xk','MarkerSize',10);

function Polygon(P,varargin);
global ax
plot(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
