function Prismatoid

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

clc;
close('all')
global ax
ax=[inf -inf inf -inf inf -inf];
Giebel=[0 1
        0 0
        0 0];
v1=[-3;-1;-16];
v2=[ 3;-1;-16];
v3=[ 3; 1;-16];
v4=[-3; 1;-16];
A=Giebel(:,1)+v1;
B=Giebel(:,2)+v2;
C=Giebel(:,2)+v3;
D=Giebel(:,1)+v4;
q=0.7;
E=Giebel(:,1)+q*v1;
F=Giebel(:,2)+q*v2;
G=Giebel(:,2)+q*v3;
H=Giebel(:,1)+q*v4;
Schrift((A+B+C+D)/4,'{\itG}','HorizontalAlignment','center','VerticalAlignment','middle','erase','none')
Schrift((A+B+C+D+E+F+G+H)/8,'{\itM}','HorizontalAlignment','center','VerticalAlignment','middle','erase','none')
Schrift((E+F+G+H)/4,'{\itD}','HorizontalAlignment','center','VerticalAlignment','middle','erase','none')
hold('on')
drawPolygon(@fill3,[A B C D],0.875*[1 1 1])
drawPolygon(@fill3,[E F G H],0.875*[1 1 1])
drawPolygon(@fill3,[A+E B+F C+G D+H]/2,0.875*[1 1 1])
drawPolygon(@plot3,[A B C D A],'k','linewidth',1.5)
drawPolygon(@plot3,[E F G H E],'k','linewidth',1.5)
drawPolygon(@plot3,[A E],'k','linewidth',1.5)
drawPolygon(@plot3,[B F],'k','linewidth',1.5)
drawPolygon(@plot3,[C G],'k','linewidth',1.5)
drawPolygon(@plot3,[D H],'k','linewidth',1.5)
hold('off')
axis(ax)
axis('off')
view(-114,12)
axis('equal')
print('-deps','Prismatoid','-opengl');

function drawPolygon(draw,P,varargin);
global ax
feval(draw,P(1,:),P(2,:),P(3,:),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
if min(P(3,:))<ax(5)
  ax(5)=min(P(3,:));
end
if max(P(3,:))>ax(6)
  ax(6)=max(P(3,:));
end

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