Retour

winding.tex

Télécharger le fichier Fichier PDF
\documentclass{article}
\usepackage{pst-solides3d}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,left=2cm,right=2cm]{geometry}
\usepackage[french]{babel}
\parindent=0pt
\makeatletter
\define@key[psset]{pst-solides3d}{dPHI}{\def\pst@solides@dPHI{#1}} % hauteur du ruban
\psset[pst-solides3d]{dPHI=5} % hauteur du ruban en degrés
\define@key[psset]{pst-solides3d}{spires}{\def\pst@solides@spires{#1}} %
\psset[pst-solides3d]{spires=10} % nombre de spires d'un ruban
 
\def\psSpiralRing{\pst@object{psSpiralRing}}
%% usage : \psSpiralRing[options]
\def\psSpiralRing@i{\@ifnextchar({\psSpiralRing@ii}{\psSpiralRing@ii(0,0,0)}}
\def\psSpiralRing@ii(#1,#2,#3){%
  \pst@killglue%
  \begingroup%
  \use@par%
\pstVerb{%
         /ri \pst@solides@rO\space def % rayon intérieur
         /rm \pst@solides@rI\space def % rayon moyen
         /spires \pst@solides@spires\space def
         /dPHI \pst@solides@dPHI\space def
/initvar_SpiralRing {
         /THETA {PHI spires 2 mul mul} def
         /x {rm ri THETA cos mul add PHI cos mul} def
         /y {rm ri THETA cos mul add PHI sin mul} def
         /z {ri THETA sin mul} def
         /dt {360 \pst@solides@resolution\space div} bind def
         /PHI 0 def
         x y z /x0 x def /y0 y def /z0 z def % S1
         /tableau_des_sommets [
          0 dt 360 dt sub{/t exch def
                    /PHI t def /THETA0 THETA def
                     x y z
                     /PHI t dt add def /THETA1 THETA def
                     x y z /x1 x def /y1 y def /z1 z def % S2
                     /PHI PHI dPHI add def
                     rm ri THETA1 cos mul add PHI cos mul
                     rm ri THETA1 cos mul add PHI sin mul
                     ri THETA1 sin mul                 % S3
                     /PHI PHI dt sub def
                     rm ri THETA0 cos mul add PHI cos mul
                     rm ri THETA0 cos mul add PHI sin mul
                     ri THETA0 sin mul  % S4
                  } for
                  ]
           def
         /Sommets {tableau_des_sommets aload pop} def
         /NbrePoints tableau_des_sommets length 3 div cvi def
        /Faces  {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [ Ni Ni 1 add  Ni 2 add Ni 3 add]
                                     } for
              } def
        /Faces_internes {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [Ni 3 add Ni 2 add Ni 1 add Ni]
                                     } for
             } def
} def
}%
\codejps{
/ruban_exterieur {
20 dict begin
   initvar_SpiralRing
/S [
  Sommets
  ] def
/F [
  Faces
  ] def
  S F generesolid
    RotX 0 ne RotY 0 ne or RotZ 0 ne or  {
        dup {RotX RotY RotZ rotateOpoint3d} solidtransform
               } if
   #1 0 ne #2 0 ne or #3 0 ne or  {
      dup {#1 #2 #3 translatepoint3d} solidtransform
              } if
   solidhue length 0 gt {
      dup solidhue 0 get solidhue 1 get solidputhuecolors
   } {
      dup (fillcolor) outputcolors
   } ifelse
end
} def
%
% tore intérieur
/tore_interieur
    {ri 0.6 mul rm [18 36] newtore
    RotX 0 ne RotY 0 ne or RotZ 0 ne or  {
        dup {RotX RotY RotZ rotateOpoint3d} solidtransform
               } if
   #1 0 ne #2 0 ne or #3 0 ne or  {
      dup {#1 #2 #3 translatepoint3d} solidtransform
              } if
 dup (Gray) outputcolors}
   def
/ruban_interieur {
20 dict begin
   initvar_SpiralRing
/S [
  Sommets
  ] def
/F [
  Faces_internes
  ] def
  S F generesolid
    RotX 0 ne RotY 0 ne or RotZ 0 ne or  {
        dup {RotX RotY RotZ rotateOpoint3d} solidtransform
               } if
   #1 0 ne #2 0 ne or #3 0 ne or  {
      dup {#1 #2 #3 translatepoint3d} solidtransform
              } if
  dup
 (fillincolor) outputcolors
end
  } def
ruban_interieur drawsolid**
tore_interieur drawsolid**
ruban_exterieur drawsolid**}%
  \endgroup%
  \ignorespaces%
}
\makeatother
 
\pagestyle{empty}
\begin{document}
\psset{SphericalCoor,viewpoint=50 20 90,Decran=50,resolution=720,lightsrc=10 10 50}
\multido{\nRotZ=0+10}{36}{%
\begin{center}
\begin{pspicture}(-5,-5)(5,5)
\psSpiralRing[incolor=yellow!50,r1=4,r0=1,hue=0 1,grid,RotZ=\nRotZ,spires=18,dPHI=5]%
\end{pspicture}
\end{center}\newpage}
 
 
\end{document}