%d'après Urs Oswald http://www.ursoswald.ch/ %prologues:=2; u:=25; % 25 = 25bp = 25 PostScript points = 30/72 in wi:=10; % width in units u he:=9; % height in units u hoehe:=he*u; % height breite:=wi*u; % width transform t, Txy; pair P[]; path p[]; color sommet[], vecteur; % 3D vectors: MetaPost type ``color'' rotX:=0; % angle of rotation around the x axis rotY:=0; % angle of rotation around the y axis rotZ:=-45; % angle of rotation around the z axis vecteur:=(0,0,0);%(1.6, 1, 2.7); % translation (in mathematical units) 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:=identity % Txy: maps 3D coordinates x,y onto reflectedabout((0,0), (1,1)) % MetaPost coordinates yscaled ypart P1 slanted (xpart P1/ypart P1) transformed t; vardef rotaX(expr SpaceVector, winkel) = % rotation of 3D vector pair yz; % ``SpaceVector'' around yz:=(greenpart SpaceVector, bluepart SpaceVector); % the x axis by the yz:=yz rotated winkel; % angle ``winkel'' (redpart SpaceVector, xpart yz, ypart yz) enddef; vardef rotaY(expr SpaceVector, winkel) = % rotation around the y axis pair zx; zx:=(bluepart SpaceVector, redpart SpaceVector); zx:=zx rotated winkel; (ypart zx, greenpart SpaceVector, xpart zx) enddef; vardef rotaZ(expr SpaceVector, winkel) = % rotation around the z axis pair xy; xy:=(redpart SpaceVector, greenpart SpaceVector); xy:=xy rotated winkel; (xpart xy, ypart xy, bluepart SpaceVector) enddef; 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; vardef Face(text t) = % returns cyclic path formed of the forsuffixes $=t: z$-- endfor % z points with suffixes in argument t cycle enddef; vardef Arete(text t) = % returns path formed of the k:=0; % z points with suffixes in argument t forsuffixes $=t: k:=k+1; endfor % count number of arguments first i:=1; forsuffixes $=t: % problem: the last z must not be followed by -- if i