Source PostScript (normalvect_to_orthobase.pps)

Retour Texte non formaté
%% syntaxe : [normal_vect] normalvect_to_orthobase %% --> imI imJ imK /normalvect_to_orthobase { 4 dict begin dup length 3 eq { aload pop normalize3d /normal_vect defpoint3d normal_vect -1 0 0 eqp3d { /imageI {0 -1 0} def /imageK {-1 0 0} def /imageJ {0 0 1} def } { %% on calcule l image de la base (I,J,K) /imageJ {normal_vect 1 0 0 vectprod3d normalize3d} def /imageK {normal_vect} def /imageI {imageJ imageK vectprod3d} def 1 0 0 imageK angle3d 0 eq { 0 1 0 normal_vect vectprod3d /imageI defpoint3d /imageJ {0 1 0} def normal_vect /imageK defpoint3d } if } ifelse } { dup length 6 eq { aload pop normalize3d /imageK defpoint3d normalize3d /imageI defpoint3d imageK imageI vectprod3d /imageJ defpoint3d } { dup length 7 eq { aload pop /alpha exch 2 div def normalize3d /imageK defpoint3d normalize3d /imageI defpoint3d imageK imageI vectprod3d /imageJ defpoint3d %% et ensuite, on fait tourner la base autour de imageK imageI alpha cos mulv3d imageJ alpha sin mulv3d addv3d imageI alpha sin neg mulv3d imageJ alpha cos mulv3d addv3d /imageJ defpoint3d /imageI defpoint3d } { %% length = 4 aload pop /alpha exch def normalize3d /normal_vect defpoint3d normal_vect -1 0 0 eqp3d { /imageI {0 -1 0} def /imageK {-1 0 0} def /imageJ {0 0 1} def } { %% on calcule l image de la base (I,J,K) /imageJ {normal_vect 1 0 0 vectprod3d normalize3d} def /imageK {normal_vect} def /imageI {imageJ imageK vectprod3d} def 1 0 0 imageK angle3d 0 eq { 0 1 0 normal_vect vectprod3d /imageI defpoint3d /imageJ {0 1 0} def normal_vect /imageK defpoint3d } if } ifelse } ifelse %% et ensuite, on fait tourner la base autour de imageK imageI alpha cos mulv3d imageJ alpha sin mulv3d addv3d imageI alpha sin neg mulv3d imageJ alpha cos mulv3d addv3d /imageJ defpoint3d /imageI defpoint3d } ifelse } ifelse imageI imageJ imageK end } def