[pstricks] multido etc...

Jean-Côme Charpentier jean-come.charpentier at wanadoo.fr
Fri Apr 13 15:09:05 CEST 2007


bessais at free.fr a écrit :
> Hi,
> 
> This code gives me the exact result I want. Is there an easier way to
> achieve that figure?

  Just a litte bit easier... rather just a little bit shorter.

> \documentclass{minimal}
> [...same as your code...]
> \rput(1.5,-1.5){(b)}

And then

> \multido{\na=0.0+.8}{6}{
> \rput(0,\na){ \spin}
> \rput(0.5,\na){
> \psrotate(0,0.25){-30}{\spin}
> }
> \rput(1,\na){
> \psrotate(0,0.25){-60}{\spin}
> }
> [...]

Here, you can see that you have :

\rput(x,\na){
  \psrotate(0,0.25){A}{\spin}
}

with x in {0.5,1.0,1.5,...} and A in {-30,-60,-90,...}

Then, you can write all this in a loop. In fact, you can also write the

\rput(0,\na){ \spin}

in this loop, assume that x is 0 and A is 0.

That gives:

\multido{\na=0.0+.8}{6}{
  \multido{\nb=0+0.5,\ia=0+-30}{7}{
    \rput(\nb,\na){
      \psrotate(0,0.25){\ia}{\spin}
    }
  }
}

Complete code:

\documentclass{minimal}
\usepackage{multido}
\usepackage{pstricks-add}
\begin{document}

\begin{pspicture}(-1,-1)(4,5)
\def\spin{%
  \psline[linecolor=magenta,linewidth=1.pt,arrowscale=1.4]
         {->}(0,0)(0,.5)
}
\psline[linecolor=blue,linestyle=dashed,linewidth=.7pt](0,-1)(0,5)
\psline[linecolor=blue,linestyle=dashed,linewidth=.7pt](3,-1)(3,5)
\psline[linecolor=magenta,linewidth=1.pt,arrowscale=1.4]{->}(-.5,1)(-.5,3)
\psline[linecolor=magenta,linewidth=1.pt,arrowscale=1.4]{<-}(3.5,1)(3.5,3)
\rput(1.5,-1.5){(b)}
\multido{\na=0.0+.8}{6}{
  \multido{\nb=0+0.5,\ia=0+-30}{7}{
    \rput(\nb,\na){
      \psrotate(0,0.25){\ia}{\spin}
    }
  }
}
\end{pspicture}
\end{document}

  Jean-Côme Charpentier




More information about the PSTricks mailing list