Source PostScript (trigospherique.pps)

Retour Texte non formaté
%% passage spherique --> cartesiennes %% les formules de passage ont été récupérées ici : %% http://fr.wikipedia.org/wiki/Coordonn%C3%A9es_polaires %% syntaxe : r theta phi rtp2xyz -> x y z /rtp2xyz { 6 dict begin /phi exch def /theta exch def /r exch def /x phi sin theta cos mul r mul def /y phi sin theta sin mul r mul def /z phi cos r mul def x y z end } def %% trace d'un arc sur une sphere de centre O %% syntaxe : r theta1 phi1 r theta2 phi2 arcspherique /arcspherique { 9 dict begin dup isstring { /option exch def } if /phi2 exch def /theta2 exch def pop /phi1 exch def /theta1 exch def /r exch def /n 12 def 1 theta1 phi1 rtp2xyz /u defpoint3d 1 theta2 phi2 rtp2xyz /v defpoint3d u v vectprod3d u vectprod3d dupp3d norme3d 1 exch div mulv3d /w defpoint3d /sinalpha u v vectprod3d norme3d def /cosalpha u v scalprod3d def /alpha sinalpha cosalpha atan def /n 12 def /pas alpha n div def gsave /t pas neg def [ n 1 add { /t t pas add store u t cos r mul mulv3d w t sin r mul mulv3d addv3d } repeat ] currentdict /option known { option } if ligne3d grestore end } def %% trace d'un arc sur une sphere de centre O %% syntaxe : r theta1 phi1 r theta2 phi2 arcspherique /arcspherique_ { 8 dict begin /phi2 exch def /theta2 exch def pop /phi1 exch def /theta1 exch def /r exch def /n 12 def 1 theta1 phi1 rtp2xyz /u defpoint3d 1 theta2 phi2 rtp2xyz /v defpoint3d u v vectprod3d u vectprod3d dupp3d norme3d 1 exch div mulv3d /w defpoint3d /sinalpha u v vectprod3d norme3d def /cosalpha u v scalprod3d def /alpha sinalpha cosalpha atan def /n 12 def /pas alpha n div def /t pas neg def [ n 1 add { /t t pas add store u t cos r mul mulv3d w t sin r mul mulv3d addv3d } repeat ] ligne3d_ end } def %% trace d'une geodesique sur une sphere de centre O %% syntaxe : r theta1 phi1 r theta2 phi2 geodesique_sphere /geodesique_sphere { 13 dict begin /phi2 exch def /theta2 exch def pop /phi1 exch def /theta1 exch def /r exch def /n 360 def 1 theta1 phi1 rtp2xyz /u defpoint3d 1 theta2 phi2 rtp2xyz /v defpoint3d u v vectprod3d u vectprod3d dupp3d norme3d 1 exch div mulv3d /w defpoint3d /sinalpha u v vectprod3d norme3d def /cosalpha u v scalprod3d def /alpha sinalpha cosalpha atan def /pas 360 n div def gsave /t pas neg def [ n 1 add { /t t pas add store u t cos r mul mulv3d w t sin r mul mulv3d addv3d } repeat ] ligne3d grestore end } def %% syntaxe : A B C trianglespherique --> trace le rtiangle ABC %% (coordonnees spheriques) /trianglespherique* { 1 dict begin /startest {true} def trianglespherique end } def /trianglespherique { 10 dict begin /C defpoint3d /B defpoint3d /A defpoint3d gsave newpath A rtp2xyz 3dto2d smoveto A B arcspherique_ B C arcspherique_ C A arcspherique_ closepath starfill currentlinewidth 0 eq {} {stroke} ifelse grestore end } def