arrows in the middle of bezier curves

Denis Girou Denis.Girou at
Mon Dec 8 16:45:39 CET 1997

This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.

    Paulo.Abreu> There is, however, a small feature that I miss a lot:
    Paulo.Abreu> the ability to put an arrow automaticaly in the middle
    Paulo.Abreu> of a curve.

  It's clear that this possibility is not currently offered, as opposite to
Xy-pic or MetaPost for instance. Alternate methods must be found according to
the different cases.

    Paulo.Abreu> E.g., here's how I draw a circle with radius R
    Paulo.Abreu> with two arrows in it:
    Paulo.Abreu> \psset{arrows=->}
    Paulo.Abreu> \parametricplot{0}{182}{%
    Paulo.Abreu>    R t cos mul R t sin mul}
    Paulo.Abreu> \parametricplot{180}{362}{%
    Paulo.Abreu>    R t cos mul R t sin mul}
    Paulo.Abreu> (note: (R*cos(t), R*sin(t)) with  0 < t <= 360 is a circle)

  It's work but using \psarc and \psarcn is easiest for this case.

    Paulo.Abreu> Anyone has the necessary math knowledge to find an
    Paulo.Abreu> analitic or parametric description of a bezier curve
    Paulo.Abreu> given its four control points?
    Paulo.Abreu> parametric description of a bezier curve
    Paulo.Abreu> given its four control points?

  Can be found in books or Web pages. From "PostScript Reference Manual":

  x(t) = a_x * t^3 + b_x * t^2 + c_x * t + x_0
  y(t) = a_y * t^3 + b_y * t^2 + c_y * t + y_0

  For a Bezier curve of four points, the coordinates of the control points are 
computed as:

  x_1 = x_0 + c_x / 3
  x_2 = x_1 + (c_x + b_x) / 3
  x_3 = x_0 + c_x + b_x + a_x

  y_1 = y_0 + c_y / 3
  y_2 = y_1 + (c_y + b_y) / 3
  y_3 = y_0 + c_y + b_y + a_y

    Paulo.Abreu> ..............................................................

    Paulo.Abreu> The thing is more complicated when I want to have
    Paulo.Abreu> arrows somewhere in the middle of a bezier curve.
    Paulo.Abreu> The only solution I found for that is to print the curve,
    Paulo.Abreu> measure on the paper where I want to put the arrows and
    Paulo.Abreu> where will they point to, and then draw a \psline with
    Paulo.Abreu> [linestyle=none] and with {->} or whatever arrow, so that
    Paulo.Abreu> the arrow falls in the curve and points the right direction.
    Paulo.Abreu> This methode is cumbersome, slow and needs lots of adjustments.

    Paulo.Abreu> ..............................................................

    Paulo.Abreu> I am also aware of the \arrows{...} command, but I think
    Paulo.Abreu> that it isn't the solution (or I am missing something there?)

  Otherway, one partial solution could be to built a variation of the \pccurve 
macro. The \pc.... macros allow to reference a position between the two points 
defined using for instance the tpos parameter. So, we can position an arrow at
the distance chosen from the points.

  There are at least two problem:

    1/ In \pccurve, the Bezier curve is defined only by the two extremums and
the control points are automatically computed according to the value of the
ncurvA and ncurvB parameters. We can vary the curve changing these parameters, 
but if you really want to fixe yourself the control points, you must built a
modified version of \pccurve which used four coordinates points as \psbezier.

    2/ We can't have automatically in this way the good orientation of the
arrow. It must be adjusted by hand (which seems not too difficult after some

  Tell us if you found a rather clean solution! Thanks.






    2 t cos mul 2 t sin mul}
    2 t cos mul 2 t sin mul}


  \tvput{\pscustom{\arrows{->}\code{-30 -20 0 3 ArrowB}}}
  \tvput[tpos=0.25]{\pscustom{\arrows{->}\code{-30 -10 0 3 ArrowB}}}
  \tvput[tpos=0.75]{\pscustom{\arrows{->}\code{-30 -10 0 3 ArrowB}}}



The list interface (subscription, information, access to the archives) is on:
Otherway to unsubscribe, send mail to pstricks-request at
with a blank subject and in body the line unsubscribe <email-address>

More information about the PSTricks mailing list