[pstricks] specifying angles by direction vectors

John Frampton jframpto at lynx.dac.neu.edu
Fri Nov 26 14:59:08 CET 2004


I wrote yesterday asking about the best way to use direction
vectors to specify angles in macros like \nccurve.  Following
Herbert's suggestion, I developed the following, which seems to
suit my purposes well.  I'm posting it because it may be of
interest to others, or perhaps someone can suggest improvements.
Specifying the parameters dirA/dirB has the effect of
specifying angleA/angleB (and overwrites whatever previous
specification they had).  A colon is used in the direction
vectors to keep the PSTricks parameter reading mechanism from
getting confused.

John Frampton
---------------------------------------------------------------
\makeatletter
\def\ps at dir(#1:#2){#1 #2 }
\def\ps at dirtoangle{\pst at number\psyunit mul exch
      \pst at number\psxunit mul atan }
\def\psset at dirA#1{\edef\psk at angleA{\ps at dir#1\noexpand\ps at dirtoangle}}
\def\psset at dirB#1{\edef\psk at angleB{\ps at dir#1\noexpand\ps at dirtoangle}}
\makeatother

%Example:

\psset{xunit=15cm,yunit=7.5cm,ncurvA=1.2}
\pspicture(0,0)(1,1)\psgrid
\rput(0,0){\pnode{A}}
\rput(1,1){\pnode{B}}
\nccurve[dirA=(4:1),dirB=(-4:-1)]{A}{B}
\nccurve[dirA=(1:1),dirB=(-1:-1)]{A}{B}
\nccurve[dirA=(1:2),dirB=(-1:-2)]{A}{B}
\psline[linestyle=dotted](.4,.8)(0,0)(.8,.2)
\psline[linestyle=dotted](.2,.8)(1,1)(.6,.2)
\endpspicture






More information about the PSTricks mailing list