
Eine Pyramide wird durch die Schnitte parallel zur
Grundfläche in dünne Schichten zerlegt. Um den Rauminhalt einer Pyramide zu
bestimmen, ersetzt man jede Schicht durch ein gerades Prisma. Die berühmten ägyptischen
Pyramiden haben ebenfalls solche treppenförmigen Seitenflächen. Die Summe der
Rauminhalte dieser Schichten ergibt dann näherungsweise den Rauminhalt der
Pyramide. Je größer die Anzahl der Schichten ist, desto genauer den Rauminhalt
der Pyramide ist.
Sei g – die Grundfläche der Pyramide und h – die Höhe der
Pyramide, dann gilt es:

V ist das Volumen der Pyramide. Diese
Formel ergibt sich aus einem Satz, dass jede Schnittfläche q parallel zur
Grundfläche einer Pyramide g der Grundfläche ähnlich ist.

X ist der Abstand von der Spitze für
jeden Querschnitt. Die Querschnitte teilen die Höhe h der Pyramide in n gleiche
Teile. Die Höhe einer Schicht ist








Das Volumen der Pyramide ergibt sich aus
den Volumen von Prismen:


Wenn n = 6, dann V = g*h*0,421
Wenn n = 10, dann V = g*h*0,385
Wenn n = 100, dann V = g*h*0,338
Der Grenzwert n→∞:

Das folgende Programm zeigt diesen
Algorithmus und berechnet das Volumen einer Pyramide, wenn die Koordinaten ihrer
vier Eckpunkte bekannt sind. Die angegebene Pyramide wird durch Betätigen des
Schalters „Volumen der Pyramide“ grafisch im Fenster dargestellt und ihres Volumen
wird berechnet. Das entsprechende MATLAB-Skript wird nachstehend dargestellt.
function Pyramide
% Kreieren des Figure-Windows
fg = figure('visible', 'off', 'position', [400,200,750,450]);
% Anlegen der einzelnen
Grafik-Komponenten
% Statischer Text
htext1 = uicontrol('style', 'text', 'string', 'Punkt A', ...
'position', [500, 400, 80, 25]);
htext2 = uicontrol('style', 'text', 'string', 'Punkt B', ...
'position', [500, 370, 80, 25]);
htext3 = uicontrol('style', 'text', 'string', 'Punkt C', ...
'position', [500, 340, 80, 25]);
htext4 = uicontrol('style', 'text', 'string', 'Punkt D', ...
'position', [500, 310, 80, 25]);
% Punkt A
axh = uicontrol('style', 'edit', 'string', ...
'Ax', 'position', [610, 400, 40, 25]);
ayh = uicontrol('style', 'edit', 'string', ...
'Ay', 'position', [660, 400, 40, 25]);
azh = uicontrol('style', 'edit', 'string', ...
'Az', 'position', [710, 400, 40, 25]);
% Punkt B
bxh = uicontrol('style', 'edit', 'string', ...
'Bx', 'position', [610, 370, 40, 25]);
byh = uicontrol('style', 'edit', 'string', ...
'By', 'position', [660, 370, 40, 25]);
bzh = uicontrol('style', 'edit', 'string', ...
'Bz', 'position', [710, 370, 40, 25]);
% Punkt C
cxh = uicontrol('style', 'edit', 'string', ...
'Cx', 'position', [610, 340, 40, 25]);
cyh = uicontrol('style', 'edit', 'string', ...
'Cy', 'position', [660, 340, 40, 25]);
czh = uicontrol('style', 'edit', 'string', ...
'Cz', 'position', [710, 340, 40, 25]);
% Punkt D
dxh = uicontrol('style', 'edit', 'string', ...
'Dx', 'position', [610, 310, 40, 25]);
dyh = uicontrol('style', 'edit', 'string', ...
'Dy', 'position', [660, 310, 40, 25]);
dzh = uicontrol('style', 'edit', 'string', ...
'Dz', 'position', [710, 310,
40, 25]);
% Ein Bedienknopf fuer das Volumen
volumen = uicontrol('style', 'pushbutton', 'string', 'Volumen der Pyramide', ...
'position', [500, 260, 170, 25], ...
'callback',
(@volumenbutton_callback));
% Statischer Text:
Volumen =
textbox1 = uicontrol('style', 'text', 'string', 'kein Ergebnis',...
'position', [500, 230, 170, 25]);
% Statischer Text
hname1 = uicontrol('style', 'text', ...
'string', 'Grundflaeche', ...
'position', [500, 200, 100, 25]);
% Statischer Text: Grundflaeche =
textbox2 = uicontrol('style', 'text', 'string', 'kein Ergebnis',...
'position', [610, 200, 170, 25]);
% Statischer Text
hname2 = uicontrol('style', 'text', ...
'string', 'Hoehe', ...
'position', [500,
170, 100, 25]);
% Statischer Text: Hoehe =
textbox3 = uicontrol('style', 'text', 'string', 'kein
Ergebnis',...
'position', [610,
170, 170, 25]);
% Statischer Text
hname3 = uicontrol('style', 'text', ...
'string', 'Autor:
Vadim Anishchenko, M.Eng.', ...
'position', [500,
40, 200, 25]);
% Die Achsen anpassen
achsen = axes('units', 'pixels', 'position', [90,
60, 350, 350]);
% Figure-Window einen Namen zuweisen
set(fg, 'name', 'Pyramide');
movegui(fg, 'center') %
Bedienoberflaeche auf Bildschirm zentrieren
set(fg, 'visible', 'on'); %
Bedienoberflaeche sichtbar machen
% 'callbacks' der Druckknoepfe
function
volumenbutton_callback(source, eventdata) %
Berechnung der Flaeche
%
Daten anlegen
ax =
str2double(get(axh, 'string'));
ay =
str2double(get(ayh, 'string'));
az =
str2double(get(azh, 'string'));
bx =
str2double(get(bxh, 'string'));
by =
str2double(get(byh, 'string'));
bz =
str2double(get(bzh, 'string'));
cx =
str2double(get(cxh, 'string'));
cy =
str2double(get(cyh, 'string'));
cz =
str2double(get(czh, 'string'));
dx =
str2double(get(dxh, 'string'));
dy =
str2double(get(dyh, 'string'));
dz =
str2double(get(dzh, 'string'));
ab=[bx-ax, by-ay, bz-az];
ac=[cx-ax, cy-ay, cz-az];
ad=[dx-ax, dy-ay, dz-az];
xVar=[ax, bx, cx, dx, ax];
yVar=[ay, by, cy, dy, ay];
zVar=[az, bz, cz, dz, az];
caVarx=[ax, cx];
caVary=[ay, cy];
caVarz=[az, cz];
bdVarx= [bx, dx];
bdVary=
[by, dy];
bdVarz= [bz, dz];
plot3(xVar, yVar, zVar, '.', 'MarkerSize', 10, 'LineStyle', '-');
hold on
plot3(caVarx, caVary, caVarz, '.', 'MarkerSize', 10, 'LineStyle', '-');
hold on
plot3(bdVarx, bdVary, bdVarz, '.', 'MarkerSize', 10, 'LineStyle', '-');
grid on % Gitternetzlinien einschalten
hold off
title('Pyramide'); % Ueberschrift des Diagramms
xlabel('X'); % Beschriftung der X-Achse
ylabel('Y'); % Beschriftung der Y-Achse
zlabel('Z'); % Beschriftung der Z-Achse
gv=cross(ab, ac); % Vektor der Grundflaeche von der
Pyramide
vprism = dot(gv, ad); %
Volumen des Prismas
v = vprism/6; % Volumen der Pyramide
vbetrag = abs(v);
g = norm(gv)/2; % Grundflaeche der Pyramide
S = norm(gv);
h = vprism/S; % Hoehe der Pyramide
hbetrag = abs(h);
set(textbox1, 'string', vbetrag); % Volumen
im GUI ausgeben
set(textbox2, 'string', g); %
Grunflaeche im GUI ausgeben
set(textbox3, 'string', hbetrag); % Hoehe im
GUI ausgeben
end
end