Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Inspired by this question, I've tried to find a command for drawing arrows along a path with PSTricks.

\documentclass{article}

\usepackage{pst-plot}

\begin{document}

\psset{unit = 2}
\begin{pspicture}(-1.2,-1.2)(1.5,1.5)
  \psaxes{->}(0,0)(-1.2,-1.2)(1.3,1.3)[$x$,0][$y$,90]
  \parametricplot[
    linecolor = red,
    linewidth = 1.2pt,
    plotstyle = ccurve
  ]{0}{180}{
    3 t mul cos t cos mul
    3 t mul cos t sin mul
  }
\end{pspicture}

\end{document}

output

Is it possible to draw arrows along anything but lines (see page 96--97 in the pstricks-add manual)? In case it is, how do I do that?

Update

Herbert has given an alternative PSTricks solution here.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You can do that with the \pscurvepoints command, which creates an array of points on the curve, and \pspolylineticks (§ 30 of pstricks-add documentation: *Ticks and other marks along a curve, pp. 107–117). What I don't understand quite well are the parameters, so I played with them. Here is an example:

\documentclass[pdf, x11names]{standalone}

\usepackage{pstricks-add}

\begin{document}

\psset{unit = 5}
\begin{pspicture}(-1.2,-1.2)(1.5,1.5)
  \psaxes{->}(0,0)(-1.2,-1.2)(1.3,1.3)[$x$,0][$y$,90]
  \parametricplot[
    linecolor = red,
    linewidth = 1.2pt,
    plotstyle = ccurve,
    plotpoints=100
  ]{0}{180}{
    3 t mul cos t cos mul
    3 t mul cos t sin mul
  }
\pscurvepoints[plotpoints=100]{0}{180}{
    3 t mul cos t cos mul
    3 t mul cos t sin mul
  }{P}
%
\pspolylineticks[Os=0,Ds=1,ticksize=0 0]{P}%
{ ds }{0}{360}% distance
\multido{\i=0+1}{100}{\psrline[linecolor = red,linewidth = 1.2pt, arrows=->,arrowscale=2](PTick\i)(2pt;{(
PTangent\i)})}%
\end{pspicture}

\end{document}

And the resulting curve:

enter image description here

share|improve this answer
    
Thanks. Now I just have to find out how to control the number of arrows. Do you know how to do that? –  Svend Tveskæg Jul 3 at 0:53
    
Not really. Seems to be a matter of ratio between the number of plot points and the value of Ds. –  Bernard Jul 3 at 1:01
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}

\psset{unit = 2}
\begin{pspicture}(-1.2,-1.2)(1.5,1.5)
  \psaxes{->}(0,0)(-1.2,-1.2)(1.3,1.3)[$x$,0][$y$,90]
  \parametricplot[algebraic,linecolor=red,linewidth=1.2pt,plotpoints=100]%
    {0}{Pi}
    { cos(3*t)*cos(t) | cos(3*t)*sin(t) }
  \multido{\rT=0.3+0.5}{12}{%
      \parametricplot[algebraic,plotpoints=2,linecolor=blue,linewidth=1.2pt,
                      arrows=->,arrowscale=1.5]%
        {\rT}{\rT\space 0.01 add}%
        { cos(3*t)*cos(t) | cos(3*t)*sin(t) }}
\end{pspicture}

\end{document}

enter image description here

The arrow is drawn with the same function and a very short line segment of only 2 points. It starts with x=cos(3*0.3)*cos(0.3) and y=cos(3*0.3)*sin(0.3). With 6 steps you have one "round" of the curve: 6*0.5=3 which is nearly Pi

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.