Functions.mp
u:=25; % 25 = 25bp = 25 PostScript points = 25/72 in
wi:=10; % width in units u
he:=9; % height in units u
hoehe:=he*u; % height
breite:=wi*u; % width
transform t, Pxy, Txy;
pair P[];
path p[];
P0=(3.2, 2.2)*u; % origin in MetaPost coordinates (bp)
P1=(-.6, -.4)/1.5; % x axis in mathematical coordinates
t:=identity % t: maps mathematical 2D coordinates
scaled u % onto MetaPost coordinates (bp)
shifted P0;
%
% Txy: maps 3D coordinates x,y onto
% MetaPost coordinates
%
% Pxy is determined by 3 e q u a t i o n s describing
% how (1,0), (0,1), and (0,0) are mapped
%
P1=(1,0)transformed Pxy; % Pxy: (1,0) --> P1
(1,0)=(0,1)transformed Pxy; % (0,1) --> (1,0)
(0,0)=(0,0)transformed Pxy; % (0,0) --> (0,0)
Txy:=Pxy transformed t; % mathematical 2D coordinates --> MetaPost coordinates
vardef getPixel(expr SpaceVector) = % returns MetaPost coordinates (bp)
% SpaceVector: type ``color'' % of spatial projection of
(redpart SpaceVector, greenpart SpaceVector) % 3D point
transformed Txy % with coordinates ``SpaceVector''
shifted (0, u*bluepart SpaceVector)
enddef;
% --------------------------------- figure 1 ---------------------------------
beginfig(1)
color viertelskreis_xy[], viertelskreis_yz[], viertelskreis_zx[], spirale[];
for i=0 upto 9:
viertelskreis_xy[i]:=(cosd 10i, sind 10i, 0);
viertelskreis_yz[i]:=(0, cosd 10i, sind 10i);
viertelskreis_zx[i]:=(sind 10i, 0, cosd 10i);
endfor
for i=0 upto 360:
spirale[i]:=(2cosd 10i, 2sind 10i, i/72);
endfor
% --- Fill halfcircles ---
fill getPixel(5(viertelskreis_xy0))
for i=1 upto 9: ..getPixel(5(viertelskreis_xy[i])) endfor
--getPixel((0,0,0))--cycle
withcolor (.8, .8, 1);
fill getPixel(5(viertelskreis_yz0))
for i=1 upto 9: ..getPixel(5(viertelskreis_yz[i])) endfor
--getPixel((0,0,0))--cycle
withcolor (.9, .9, 1) ;
fill getPixel(5(viertelskreis_zx0))
for i=1 upto 9: ..getPixel(5(viertelskreis_zx[i])) endfor
--getPixel((0,0,0))--cycle
withcolor (.6, .6, 1);
% --- Grid ---
color gr;
gr=.5white;
for i=0 upto 5:
draw getPixel((i,0,0))--getPixel((i,5,0)) withcolor gr;
draw getPixel((0,i,0))--getPixel((5,i,0)) withcolor gr;
draw getPixel((0,i,0))--getPixel((0,i,5)) withcolor gr;
draw getPixel((0,0,i))--getPixel((0,5,i)) withcolor gr;
draw getPixel((0,0,i))--getPixel((5,0,i)) withcolor gr;
draw getPixel((i,0,0))--getPixel((i,0,5)) withcolor gr;
endfor
% --- End Grid ---
% --- Frame ---
draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
% --- Axes ---
drawarrow getPixel((0, 0, 0))--getPixel((6, 0, 0));
label.llft(btex $x$ etex, getPixel((6, 0, 0))+(0, 1mm));
drawarrow getPixel((0, 0, 0))--getPixel((0, 6, 0));
label.rt (btex $y$ etex, getPixel((0, 6, 0)));
drawarrow getPixel((0, 0, 0))--getPixel((0, 0, 6));
label.top (btex $z$ etex, getPixel((0, 0, 6)));
% --- Draw spiral ---
color sp;
for i=0 upto 359:
sp:=(1+cosd(10i))*.5white;
fill getPixel((0, 0, bluepart spirale[i]))--getPixel(spirale[i])
--getPixel(spirale[i+1])--cycle withcolor sp;
if i=0:
draw getPixel(spirale[i])--getPixel((0, 0, 0)) ;
fi
draw getPixel(spirale[i])--getPixel(spirale[i+1]) ;
endfor
endfig;
% --------------------------------- end of figure 1 ---------------------------------
end