/CylindreDict 100 dict def CylindreDict begin /facette { Xfacette Yfacette Zfacette 3dto2d moveto theta 1 theta incrementANGLE add {% /theta1 exch def /Xpoint Rcylindre theta1 cos mul def /Ypoint Rcylindre theta1 sin mul def /Zpoint H def PointsApresTransformations 3dto2d lineto } for H 1 H incrementHAUTEUR add { /H1 exch def /Xpoint Rcylindre theta incrementANGLE add cos mul def /Ypoint Rcylindre theta incrementANGLE add sin mul def /Zpoint H1 def PointsApresTransformations 3dto2d lineto } for theta incrementANGLE add -1 theta {% /theta1 exch def /Xpoint Rcylindre theta1 cos mul def /Ypoint Rcylindre theta1 sin mul def /Zpoint H incrementHAUTEUR add def PointsApresTransformations 3dto2d lineto } for H incrementHAUTEUR add -1 H { /H1 exch def /Xpoint Rcylindre theta cos mul def /Ypoint Rcylindre theta sin mul def /Zpoint H1 def PointsApresTransformations 3dto2d lineto } for } def /cylindre { 0 incrementANGLE 360 {% /theta exch def 0 incrementHAUTEUR Hcylindre incrementHAUTEUR sub {% /H exch def % newpath /X1 Rcylindre theta cos mul def /Y1 Rcylindre theta sin mul def /Z1 H def /Xpoint X1 def /Ypoint Y1 def /Zpoint Z1 def PointsApresTransformations /Zfacette ED /Yfacette ED /Xfacette ED % coordonnées du centre de la facette /Xpoint Rcylindre theta incrementANGLE 2 div add cos mul def /Ypoint Rcylindre theta incrementANGLE 2 div add sin mul def /Zpoint H incrementHAUTEUR 2 div add def PointsApresTransformations /Zcentre ED /Ycentre ED /Xcentre ED % ?? % Point sur l'axe du cylindre % à la même hauteur que M1 /Zpoint H incrementHAUTEUR 2 div add def /Xpoint 0 def /Ypoint 0 def PointsApresTransformations /zM1 ED /yM1 ED /xM1 ED % normale à la facette /xN Xcentre xM1 sub def /yN Ycentre yM1 sub def /zN Zcentre zM1 sub def % rayon vers point de vue /RXvue XpointVue Xcentre sub def /RYvue YpointVue Ycentre sub def /RZvue ZpointVue Zcentre sub def % test de visibilité /PSfacette xN RXvue mul yN RYvue mul add zN RZvue mul add def % vecteur centre de la facette vers la source de lumière /VxLight xLight Xcentre sub def /VyLight yLight Ycentre sub def /VzLight zLight Zcentre sub def % norme /normeL VxLight dup mul VyLight dup mul VzLight dup mul add add sqrt def /normeN xN dup mul yN dup mul zN dup mul add add sqrt def % produit scalaire /PSLight VxLight xN mul VyLight yN mul add VzLight zN mul add def /CosCouleur PSLight normeL normeN mul div ChangeSigne def condition { facette %H_S CosCouleur sethsbcolor fill nocolor toDraw } if } for } for } def /Face_superieure { % centre de la face supérieure /Xpoint 0 def /Zpoint Hcylindre def /Ypoint 0 def PointsApresTransformations /CzFaceSup ED /CyFaceSup ED /CxFaceSup ED % centre de la face inférieure /Xpoint 0 def /Zpoint 0 def /Ypoint 0 def PointsApresTransformations /CzFaceInf ED /CyFaceInf ED /CxFaceInf ED % Normale à la face supérieure /nXFaceSup CxFaceSup CxFaceInf sub def /nYFaceSup CyFaceSup CyFaceInf sub def /nZFaceSup CzFaceSup CzFaceInf sub def % rayon vers point de vue verd la face supérieure /RXvueSup XpointVue CxFaceSup sub def /RYvueSup YpointVue CyFaceSup sub def /RZvueSup ZpointVue CzFaceSup sub def % Visibilité face supérieure /PSfaceSup RXvueSup nXFaceSup mul RYvueSup nYFaceSup mul add RZvueSup nZFaceSup mul add def } def /FaceSup { /TableauxPoints [ 0 1 359 {% on décrit le cercle /theta exch def [ /Xpoint Rcylindre theta cos mul def /Ypoint Rcylindre theta sin mul def /Zpoint Hcylindre def PointsApresTransformations 3dto2d ] } for ] def TableauxPoints 0 get aload pop moveto 0 1 359 { /compteur exch def TableauxPoints compteur get aload pop lineto } for } def /Face_inferieure{ % centre de la face inférieure /Xpoint 0 def /Zpoint 0 def /Ypoint 0 def PointsApresTransformations /CzFaceInf ED /CyFaceInf ED /CxFaceInf ED % rayon de la face inférieure vers le point de vue /RXvueInf XpointVue CxFaceInf sub def /RYvueInf YpointVue CyFaceInf sub def /RZvueInf ZpointVue CzFaceInf sub def % centre de la face supérieure /Xpoint 0 def /Zpoint Hcylindre def /Ypoint 0 def PointsApresTransformations /CzFaceSup ED /CyFaceSup ED /CxFaceSup ED % Normale à la face inférieure /nXFaceInf CxFaceInf CxFaceSup sub def /nYFaceInf CyFaceInf CyFaceSup sub def /nZFaceInf CzFaceInf CzFaceSup sub def % Visibilité face inférieure /PSfaceInf RXvueInf nXFaceInf mul RYvueInf nYFaceInf mul add RZvueInf nZFaceInf mul add def } def /FaceInf { /TableauxPoints [ 0 1 359 {% on décrit le cercle /theta exch def [ /Xpoint Rcylindre theta cos mul def /Ypoint Rcylindre theta sin mul def /Zpoint 0 def PointsApresTransformations 3dto2d ] } for ] def TableauxPoints 0 get aload pop moveto 0 1 359 { /compteur exch def TableauxPoints compteur get aload pop lineto } for } def end %