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.

I want to create a spiral that is composed of equidistant segments as shown in the following figure. I tried to draw it with various methods. The colors are used to distinguish each method from the others.

enter image description here

The methods I used are:

\translate(!CP \tx@UserCoor) with \multido and \lineto

It is my original idea.

\makeatletter
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=red]
{
    \moveto(0,0)
    \multido{\r=0.1+0.1}{89}{\translate(!CP \tx@UserCoor)\lineto(!1 \r\space sqrt 700 mul PtoC)}
}
\end{pspicture}
\makeatother

\translate(!CP \tx@UserCoor) with \multido and \psline

It is my original idea.

\makeatletter
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=green]
{
    \moveto(0,0)
    \multido{\r=0.1+0.1}{89}{\translate(!CP \tx@UserCoor)\psline(!1 \r\space sqrt 700 mul PtoC)}
}
\end{pspicture}
\makeatother

\rlineto with \multido

It is my original idea.

\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=blue]
{
    \moveto(0,0)
    \multido{\r=0.1+0.1}{89}{\rlineto(!1 \r\space sqrt 700 mul PtoC)}
}
\end{pspicture}

\psVector with \multido

It is Herbert's idea.

\begin{pspicture}[showgrid](-5,-5)(5,5)
    \psset{showpoints,dotstyle=o,dotscale=2,linecolor=red}
    \psStartPoint(0,0)
    \multido{\r=0.1+0.1}{89}{\psVector[arrows=-](!1 \r\space sqrt 700 mul PtoC)}
\end{pspicture}

\psnline with \multido, concatenated \points and \expandafter

It is Jake's idea.

\begin{pspicture}[showgrid](-5,-5)(5,5)
\def\points{(0,0)}%
\multido{\r=0.1+0.1}{89}{\xdef\points{\points(!1 \r\space sqrt 700 mul PtoC)}}
\psset{linecolor=green}
\expandafter\psrline\points
\end{pspicture}

\curvepnodes with temporary variables

It is Christoph's idea.

\begin{pspicture}[showgrid](-5,-5)(5,5)
  \pstVerb{tx@NodeDict begin /myX -1 def /myY 0 def end }%
  \curvepnodes[plotpoints=90]{0}{89}{%
    myX myY
    t 0.1 mul sqrt 700 mul 1 exch PtoC
    3 -1 roll add 3 1 roll add exch
    2 copy /myY ED /myX ED
  }{P}
  \psnline[linecolor=blue](0,\Pnodecount){P} 
\end{pspicture}

\psparametricplot with temporary variables

It is Christoph's idea applied to \psparametricplot.

\begin{pspicture}[showgrid](-5,-5)(5,5)
  \pstVerb{/myX -1 def /myY 0 def}%
  \psparametricplot[plotpoints=90,linecolor=red]{0}{89}{%
    myX myY
    t 0.1 mul sqrt 700 mul 1 exch PtoC
    3 -1 roll add 3 1 roll add exch
    2 copy /myY ED /myX ED
  }
\end{pspicture}

\curvepnodes with for loop

It is Christoph's idea.

\begin{pspicture}[showgrid](-5,-5)(5,5)
  \curvepnodes[plotpoints=90]{0}{89}{%
    -1 0 
        0 1 t
        {
            0.1 mul sqrt 700 mul 1 exch PtoC
            3 -1 roll add 3 1 roll add exch
    } for 
  }{P}
  \psnline[linecolor=green](0,\Pnodecount){P} 
\end{pspicture}

\psparametricplot with for loop

It is Christoph's idea applied to \psparametricplot.

\begin{pspicture}[showgrid](-5,-5)(5,5)
  \psparametricplot[plotpoints=90,linecolor=blue]{0}{89}{%
    -1 0 
        0 1 t
        {
            0.1 mul sqrt 700 mul 1 exch PtoC
            3 -1 roll add 3 1 roll add exch
    } for 
  } 
\end{pspicture}

The complete code

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}
\psset{showpoints,dotstyle=o,dotscale=2}

\begin{document}


\makeatletter
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=red]
{
    \moveto(0,0)
    \multido{\r=0.1+0.1}{89}{\translate(!CP \tx@UserCoor)\lineto(!1 \r\space sqrt 700 mul PtoC)}
}
\end{pspicture}
\makeatother



\makeatletter
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=green]
{
    \moveto(0,0)
    \multido{\r=0.1+0.1}{89}{\translate(!CP \tx@UserCoor)\psline(!1 \r\space sqrt 700 mul PtoC)}
}
\end{pspicture}
\makeatother


\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=blue]
{
    \moveto(0,0)
    \multido{\r=0.1+0.1}{89}{\rlineto(!1 \r\space sqrt 700 mul PtoC)}
}
\end{pspicture}


\begin{pspicture}[showgrid](-5,-5)(5,5)
    \psset{showpoints,dotstyle=o,dotscale=2,linecolor=red}
    \psStartPoint(0,0)
    \multido{\r=0.1+0.1}{89}{\psVector[arrows=-](!1 \r\space sqrt 700 mul PtoC)}
\end{pspicture}


\begin{pspicture}[showgrid](-5,-5)(5,5)
\def\points{(0,0)}%
\multido{\r=0.1+0.1}{89}{\xdef\points{\points(!1 \r\space sqrt 700 mul PtoC)}}
\psset{linecolor=green}
\expandafter\psrline\points
\end{pspicture}


\begin{pspicture}[showgrid](-5,-5)(5,5)
  \pstVerb{tx@NodeDict begin /myX -1 def /myY 0 def end }%
  \curvepnodes[plotpoints=90]{0}{89}{%
    myX myY
    t 0.1 mul sqrt 700 mul 1 exch PtoC
    3 -1 roll add 3 1 roll add exch
    2 copy /myY ED /myX ED
  }{P}
  \psnline[linecolor=blue](0,\Pnodecount){P} 
\end{pspicture}

\begin{pspicture}[showgrid](-5,-5)(5,5)
  \pstVerb{/myX -1 def /myY 0 def}%
  \psparametricplot[plotpoints=90,linecolor=red]{0}{89}{%
    myX myY
    t 0.1 mul sqrt 700 mul 1 exch PtoC
    3 -1 roll add 3 1 roll add exch
    2 copy /myY ED /myX ED
  }
\end{pspicture}

\begin{pspicture}[showgrid](-5,-5)(5,5)
  \curvepnodes[plotpoints=90]{0}{89}{%
    -1 0 
        0 1 t
        {
            0.1 mul sqrt 700 mul 1 exch PtoC
            3 -1 roll add 3 1 roll add exch
    } for 
  }{P}
  \psnline[linecolor=green](0,\Pnodecount){P} 
\end{pspicture}

\begin{pspicture}[showgrid](-5,-5)(5,5)
  \psparametricplot[plotpoints=90,linecolor=blue]{0}{89}{%
    -1 0 
        0 1 t
        {
            0.1 mul sqrt 700 mul 1 exch PtoC
            3 -1 roll add 3 1 roll add exch
    } for 
  } 
\end{pspicture}

\end{document}

Questions

  1. How to use \psplot here?

  2. Are there any other methods left?

  3. When using \lineto, \psline and \rlineto, how to make showpoints work?

share|improve this question
5  
your Q looks like an answer with it's multiple scrolling needed :) –  texenthusiast Nov 26 '13 at 19:34
    
@texenthusiast: I don't think so. :-) –  I am who I say I am Nov 26 '13 at 19:35
    
If there is no answer then I will delete this question shortly... –  I am who I say I am Nov 27 '13 at 8:41
    
They all seem to use the same formula (a square root multiplied by 700 and then transformed to Cartesian coordinates)? What is that formula for someone inexperienced with PSTricks notation of coordinates? What is the angle between the points? –  Qrrbrbirlbel Nov 30 '13 at 8:01
    
@Qrrbrbirlbel: See Jake's answer. –  I am who I say I am Nov 30 '13 at 16:29
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.