% /facetteSphereII { /Xpoint Rsphere theta cos mul phi cos mul def /Ypoint Rsphere theta sin mul phi cos mul def /Zpoint Rsphere phi sin mul def PointsApresTransformations 3dto2d moveto theta 1 theta increment add {% /theta1 exch def /Xpoint Rsphere theta1 cos mul phi cos mul def /Ypoint Rsphere theta1 sin mul phi cos mul def /Zpoint Rsphere phi sin mul def PointsApresTransformations 3dto2d lineto } for phi 1 phi increment add { /phi1 exch def /Xpoint Rsphere theta increment add cos mul phi1 cos mul def /Ypoint Rsphere theta increment add sin mul phi1 cos mul def /Zpoint Rsphere phi1 sin mul def PointsApresTransformations 3dto2d lineto } for theta increment add -1 theta {% /theta1 exch def /Xpoint Rsphere theta1 cos mul phi increment add cos mul def /Ypoint Rsphere theta1 sin mul phi increment add cos mul def /Zpoint Rsphere phi increment add sin mul def PointsApresTransformations 3dto2d lineto } for phi increment add -1 phi { /phi1 exch def /Xpoint Rsphere theta cos mul phi1 cos mul def /Ypoint Rsphere theta sin mul phi1 cos mul def /Zpoint Rsphere phi1 sin mul def PointsApresTransformations 3dto2d lineto } for } def % /MaillageSphereII { /ThetaStart 0 def departPhi increment 90 increment sub {% /phi exch def ThetaStart increment 360 ThetaStart add increment sub {% /theta exch def % Centre de la facette /Xpoint Rsphere theta increment 2 div add cos mul phi increment 2 div add cos mul def /Ypoint Rsphere theta increment 2 div add sin mul phi increment 2 div add cos mul def /Zpoint Rsphere phi increment 2 div add sin mul def PointsApresTransformations /zCentreFacette ED /yCentreFacette ED /xCentreFacette ED % normale à la facette /nXfacette xCentreFacette CX sub def /nYfacette yCentreFacette CY sub def /nZfacette zCentreFacette CZ sub def % rayon vers point de vue /RXvue XpointVue xCentreFacette sub def /RYvue YpointVue yCentreFacette sub def /RZvue ZpointVue zCentreFacette sub def % test de visibilité /PSfacette RXvue nXfacette mul RYvue nYfacette mul add RZvue nZfacette mul add def % norme normale à la facette : rayon de la sphère % /NormeN {nXfacette dup mul % nYfacette dup mul % nZfacette dup mul % add add sqrt} def % vecteur centre de la facette vers la source de lumière /VxLight xLight xCentreFacette sub def /VyLight yLight yCentreFacette sub def /VzLight zLight zCentreFacette sub def % norme /normeL VxLight dup mul VyLight dup mul VzLight dup mul add add sqrt def % produit scalaire /PSLight VxLight nXfacette mul VyLight nYfacette mul add VzLight nZfacette mul add def /CosCouleur PSLight normeL Rsphere mul div def condition { gsave newpath H_S CosCouleur sethsbcolor facetteSphereII closepath fill grestore facetteSphereII } if } for /ThetaStart ThetaStart sepTheta add def } for } def