[pstricks] Vector fields

Michael Sharpe msharpe at ucsd.edu
Sat May 30 01:37:49 CEST 2009

This code does the same thing, but may be easier to understand.

\begin{pspicture}[showgrid=true](-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\multido{\ia=-5+1}{11}{%
\multido{\ib=-5+1}{11}{%
\rput{(!\ia\space\ib)}(\ia,\ib){\psline(-.4,0)(.4,0)}
}}
\end{pspicture}

To change to your case (field <2x,y>) you would just change the term
{(!\ia\space\ib)} to {(!\ia\space 2 mul \ib)}, the point being that
you are rotating a line segment to take the direction of the field.

Michael

On May 29, 2009, at 1:15 PM, Hamed Al-Sulami wrote:

> Hi,
> Guys can somebody explain for me the code of the following
>
> \SpecialCoor
>
> \begin{pspicture}(-6,-6)(6,6)
>   \psaxes{<->}(0,0)(-6,-6)(6,6)
>   \psset{arrows=->}
>   \multido{\ia=-5+1}{11}{%
>     \multido{\ib=-5+1}{11}{%
>       \pstVerb{/x \ia\space def
>                /y \ib\space def
>                y 0 eq
>                  {/ValueTempA 0 def
>                   /ValueTempB 0.5 def}
>                  {/ValueTempZ 2 1 x x mul y y mul div add sqrt mul def
>                   /ValueTempA 1 ValueTempZ div def
>                   /ValueTempB x y ValueTempZ mul div def}
>                  ifelse}
>       \psline(! x ValueTempA sub y ValueTempB sub)