# [pstricks] Making Direction Fields; also coordinates as functions inside loops

Denis Girou Denis.Girou at idris.fr
Thu Jan 11 18:41:25 CET 2001

>>>>> "Michael.Sharpe" == Michael J Sharpe <msharpe at euclid.ucsd.edu> writes:

Michael.Sharpe> Here's another way making use of the ability of \SpecialCoor pointed
Michael.Sharpe> out by Denis to do the picture using \pstcustom.

This is clearly the best solution that we have (it allow also to use the
straightforward way to set the arrows). I can only suggest to parametrize
the direction of the vector field for greater flexibility.

\documentclass[a4paper]{article}

\usepackage{pst-plot}

% From Michael Sharpe

\SpecialCoor

\def\drawseg#1#2{%
\pscustom{%
\translate(#1,#2)
\rotate{(\dirseg{#1}{#2})}    % Vector in direction of field at x=#1,y=#2
\psline(-.25,0)(.25,0)}}

\def\dirseg#1#2{-#2,#1}         % Default direction field ($y'=-x/y$)

\pagestyle{empty}

\begin{document}

\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\multido{\n=-5+1}{11}{%
\multido{\N=-5+1}{11}{%
\ifnum\N=0
\ifnum\n=0
\else
\drawseg{\n}{\N}
\fi
\else
\drawseg{\n}{\N}
\fi}}
\end{pspicture}

\def\dirseg#1#2{#2,#1}          % Direction field example ($y'=x/y$)

\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\psset{arrows=->}
\multido{\n=-5+1}{11}{%
\multido{\N=-5+1}{11}{%
\ifnum\N=0
\ifnum\n=0
\else
\drawseg{\n}{\N}
\fi
\else
\drawseg{\n}{\N}
\fi}}
\end{pspicture}

\end{document}

Thanks Michael!

D.G.