# [pstricks] computed coordinates

Michael Sharpe msharpe at ucsd.edu
Sun Apr 25 18:10:21 CEST 2010

```On Apr 25, 2010, at 7:00 AM, Zbigniew Nitecki wrote:

> I'm still confused about how to introduce computations on inputs into a macro.
>
> I am trying to create a macro to then include in a \multido for drawing an arrow
> indicating a vector field.  The following two-dimensional version works fine: I can
> insert a postscript formula for the components of the last two inputs and get a reasonable
> picture.
> 	\newcommand{\vectorfieldtwo}[8]{
> 			\multido{\rx=#1+#2}{#3}{%
> 				\multido{\ry=#4+#5}{#6}{%
> 						}}
> 				}%2-dim vectorfield: x starts at #1, increments by #2, #3 iterations;
> 				%y starts at #4, increments by #5, #6 iterations;
> 				%#7, #8 components of vector (in terms of \rx & \ry, postscript style
>
> The following also works in 3D, but I am giving both endpoints of the vector explicitly:
> 	\newcommand{\vecThree}[6]{\pstThreeDLine[arrows=->]%
> 		(#1\space,#2\space,#3\space)(#4\space,#5\space,#6\space)
> 	}
> 		%arrow from (#1,#2,#3) to (#4,#5,#6)
> However, when I try to do the following, which uses as input the components of the vector
> instead of explicit coordinates for its endpoint, I get an error message (the error is the same
> whether I use an exclamation before the coordinates or not):
>
> 	\newcommand{\vecatThree}[6]{\pstThreeDLine[arrows=->]%
> 		(#1\space  #2\space  #3\space)
> 	}
> 		% arrow pinned to (#1,#2,#3) with components (#4,#5,#6)
>
>> Runaway argument?
>> \@nil \edef \pst at coors {\pst at coor \pst at coors }\@ifnextchar ({\pst@@getcoors \ET
>> C.
>> ! Paragraph ended before \cartesianIIID at coor was complete.
>>                    \par
>> l.41
>
> I would like, ultimately, to insert such a macro either into a multido as in the 2-dim example,
> or to do something more sophisticated:  given a surface plotted via say parametricplotThreeD,
> to insert a formula for the entries #1, #2, and #3 as well (to plot the vectors only along the points
> of the surface).
>
> I would also prefer to use the algebraic rather than postscript form for formulas, but that is a minor
> and separate matter.
>