1
\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid](5,5)
\psline[arrows=->](1,1)(1,1)
\psellipticarc[arrows=->](2.5,2.5)(1,2){0}{0}
\psellipticarcn[arrows=->](2.5,2.5)(2,1){0}{0}
\psarc[arrows=->](2.5,2.5){1}{0}{0}
\psarcn[arrows=->](2.5,2.5){2}{0}{0}
\end{pspicture}
\end{document}

enter image description here

Question:

Should zero-length \psline[arrows=->](1,1)(1,1) be displayed?

Why does zero-length \psellipticarc get rendered while zero-length \psarc does not?

  • (1,1) to (1,1) is a rather short line? did you intend (0,0)(1,1) ? – David Carlisle Jan 6 at 15:44
  • 1
    @chishimotoji that is specifying the start and end point to be at the same place what kind of line do you expect to see in that case? "short" was an under-statement, it has length 0pt. – David Carlisle Jan 6 at 15:58
  • 1
    The coordinates of \psline[arrows=->](1,1)(1,1) are nonsense and if you want an arrow for such coordinates you get nonsense... – user2478 Jan 6 at 18:20
  • 1
    @Herbert: So \psline[arrows=->](1,1)(1,1) should be rendered as "nothing" or an arrow? The current condition in both PSTricks and TikZ, it produces an arrow that looks like a bug. – Gold Digging Programmer Jan 6 at 18:24
  • 1
    With pstricks.tex from archiv.dante.de/~herbert/texnik/tex/generic/pstricks you can use \psLine (uppercase L) which can have only one or two pairs of coordinates, but will test for a length between the points. Will later be on CTAN. – user2478 Jan 7 at 18:31
1

With an up-to-date pstricks.tex from http://archiv.dante.de/~herbert/texnik/tex/generic/pstricks/

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
    \begin{pspicture}[showgrid](5,5)
    \psLine[arrows=->](1,1)(1,1)
    \psellipticarc[arrows=->](2.5,2.5)(1,2){0}{0}
    \psellipticarcn[arrows=->](2.5,2.5)(2,1){0}{0}
    \psarc[arrows=->](2.5,2.5){1}{0}{0}
    \psarcn[arrows=->](2.5,2.5){2}{0}{0}
    \end{pspicture}
\end{document}

you'll get an empty grid.enter image description here

1

I can only reproduce the single arrow for \psline[arrows=->](1,1)(1,1) because I use the latest TeX Live 2018 update. I think someone has changed the arc-related macros several days ago.

A single arrow for the zero-length line is a feature that is intentionally kept as it is because according to someone it is useful for drawing zero-length vectors. TikZ also has the same feature, right? :-)

So if you want to get nothing for a zero-length line, do modify the \psline as follows.

\makeatletter
\def\psline{\pst@object{psline}}% a special Line 
\def\psline@i{\pst@getarrows{\begin@OpenObj \pst@getcoors[\psline@ii}}
\def\psline@ii{%
    \addto@pscode{
      \ifPst@noCurrentPoint\else\pst@cp\fi% current point?
      4 copy Pyth2 \psk@arrowlength ge 
        { \psline@iii \tx@Line }% arc and lineto type
        { pop pop pop pop } ifelse }%
  \end@OpenObj}
\makeatother

Here I present an example in which zero-length lines are practically useful in our life. Of course we can use conditional macro to get the same result.

\documentclass[pstricks,border=1cm]{standalone}
\usepackage{pstricks-add}
\makeatletter
\def\psline{\pst@object{psline}}% a special Line 
\def\psline@i{\pst@getarrows{\begin@OpenObj \pst@getcoors[\psline@ii}}
\def\psline@ii{%
    \addto@pscode{
      \ifPst@noCurrentPoint\else\pst@cp\fi% current point?
      4 copy Pyth2 \psk@arrowlength ge 
        { \psline@iii \tx@Line }% arc and lineto type
        { pop pop pop pop } ifelse }%
  \end@OpenObj}
\makeatother

\usepackage[nomessages]{fp}
\newcommand\const[3][3]{%
    \expandafter\FPeval\csname#2\endcsname{round(#3:#1)}%
    \pstVerb{/#2 \csname#2\endcsname\space def}%
}
\newcommand\Const[3][3]{\begingroup\edef\temp{\endgroup\noexpand\const[#1]{#2}{#3}}\temp}

\Const{Tpeak}{1}
\Const{Theta}{80/180*pi}
\Const{Gravity}{10}
\Const{SpeedFactor}{0.2}
\Const{FPS}{11}

\def\X#1{Vinit*cos(Theta)*#1}
\def\Y#1{Vinit*sin(Theta)*#1-Gravity*pow(2,#1)/2}

\Const{Vinit}{Tpeak*Gravity/sin(Theta)}
\Const{Xpeak}{\X{Tpeak}}
\Const{Ypeak}{\Y{Tpeak}}

\def\point#1{%
    \pnode(!Vinit Theta RadToDeg 2 copy cos mul #1 mul 3 1 roll sin mul #1 mul Gravity #1 2 exp mul 2 div sub){P}
    \pscircle[linecolor=red,fillstyle=solid,fillcolor=yellow](P){3pt}
    \pnode[!Vinit Theta RadToDeg cos mul SpeedFactor mul 0](P){PX}
    \pnode[!0 Vinit Theta RadToDeg sin mul Gravity #1 mul sub SpeedFactor mul](P){PY}
    %
    \psline[linecolor=blue]{->}(P)(PX)
    \psline[linecolor=magenta]{->}(P)(PX|PY)
    \psline[linecolor=blue]{->}(P)(PY)
}


\Const{DeltaTime}{1/\FPS}
\Const[0]{TotalFrames}{\FPS*2*Tpeak}
\Const[0]{TotalFrames}{TotalFrames+1}

\begin{document}
\multido{\nt=0.000+\DeltaTime}{\TotalFrames}{%
\begin{pspicture}[showgrid=false](0,-35pt)(2\dimexpr\Xpeak\psxunit\relax,\dimexpr\Ypeak\psyunit+7pt\relax)
    \parabola[linewidth=0.5\pslinewidth,linestyle=dashed](0,0)(\Xpeak,\Ypeak)
    \point{\nt}
\end{pspicture}}
\end{document}

enter image description here

1

Try out this:

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid](5,5)
\psline[arrows=->](1,1)(1,1)
\psline[arrows=->](0,1)(1,0)
\psellipticarc[arrows=->](2.5,2.5)(1,2){0}{360}
\psellipticarcn[arrows=->](2.5,2.5)(2,1){0}{360}
\psarc[arrows=->](2.5,2.5){1}{0}{360}
\psarcn[arrows=->](2.5,2.5){2}{0}{360}
\end{pspicture}
\end{document}

What do you want to get when letting start a vector (\psline) at the same point where it ends? Just produce an arrowhead with a given direction?

Note: \psarc[arrows=->](2.5,2.5){1}{0}{360}

The parentheses give the coordinates of the center of the arc of the circle. The first mandatory argument gives the radius of the arc of the circle. The second and third mandatory arguments give the starting and ending angle of the arc.

When both angles are chosen to 0, there is no arc to be drawn, as well as with the ellipses ... I cannot reproduce that the elliptic arcs are drawn.

\psellipticarc[arrows=->](2.5,2.5)(1,2){0}{0}
\psellipticarcn[arrows=->](2.5,2.5)(2,1){0}{0}

enter image description here

  • I think you are now using the latest update so you cannot reproduce the elliptical arcs. – Gold Digging Programmer Jan 6 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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