/RaccordDict 100 dict def RaccordDict begin /dA 5 def /MaillageRaccord {% 180 dA 180 theta add { /T ED 0 dT 360 { /Theta ED /rayon1 {a T cos mul r add a add} bind def % M1 /x1 rayon1 Theta cos mul def /y1 rayon1 Theta sin mul def /z1 a T sin mul zI add def /Xpoint x1 def /Ypoint y1 def /Zpoint z1 def PointsApresTransformations /Z1 ED /Y1 ED /X1 ED % M2 /rayon2 {a T dA add cos mul r add a add} bind def /x2 rayon2 Theta cos mul def /y2 rayon2 Theta sin mul def /z2 a T dA add sin mul zI add def /Xpoint x2 def /Ypoint y2 def /Zpoint z2 def PointsApresTransformations /Z2 ED /Y2 ED /X2 ED % M3 /x3 rayon2 Theta dT add cos mul def /y3 rayon2 Theta dT add sin mul def /z3 z2 def /Xpoint x3 def /Ypoint y3 def /Zpoint z3 def PointsApresTransformations /Z3 ED /Y3 ED /X3 ED % M4 /x4 rayon1 Theta dT add cos mul def /y4 rayon1 Theta dT add sin mul def /z4 z1 def /Xpoint x4 def /Ypoint y4 def /Zpoint z4 def PointsApresTransformations /Z4 ED /Y4 ED /X4 ED %% centre de la face /xF {X1 X2 add X3 add X4 add 4 div} bind def /yF {Y1 Y2 Y3 Y4 add add add 4 div} bind def /zF {Z1 Z2 Z3 Z4 add add add 4 div} bind def %% vecteur : centre de la face -> point de vue /xV {XpointVue xF sub } bind def /yV {YpointVue yF sub } bind def /zV {ZpointVue zF sub } bind def %% distance % /D {xV dup mul yV dup mul add zV dup mul add sqrt} bind def %% normale % les vecteurs de la face /V1x X2 X1 sub def /V1y Y2 Y1 sub def /V1z Z2 Z1 sub def /V2x X3 X2 sub def /V2y Y3 Y2 sub def /V2z Z3 Z2 sub def % le produit vectoriel /xN V1y V2z mul V1z V2y mul sub def /yN V1x V2z mul V1z V2x mul sub neg def /zN V1x V2y mul V1y V2x mul sub def % le produit scalaire des 2 vecteurs /PSfacette xV xN mul yV yN mul add zV zN mul add def % vecteur centre de la facette vers la source de lumière /VxLight xLight xF sub def /VyLight yLight yF sub def /VzLight zLight zF sub def % norme /normeL VxLight dup mul VyLight dup mul VzLight dup mul add add sqrt def % produit scalaire /PSLight VxLight xN mul VyLight yN mul add VzLight zN mul add def /normeN xN dup mul yN dup mul zN dup mul add add sqrt def /CosCouleur PSLight normeL normeN mul div def condition { /facette{ %newpath X1 Y1 Z1 3dto2d moveto X2 Y2 Z2 3dto2d lineto X3 Y3 Z3 3dto2d lineto X4 Y4 Z4 3dto2d lineto %closepath } def facette %H_S CosCouleur sethsbcolor fill nocolor toDraw} if } for } for } def end