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.

Consider the following MWE first.

\documentclass[pstricks,border=12pt]{standalone}
\SpecialCoor
\usepackage{multido}
\begin{document}

% draw the tangential lines
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=red]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        \translate(!!CP)
        \lineto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
    }       
}
\end{pspicture}

% draw the radial lines
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=blue]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        \translate(!!CP)
        \moveto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
        \psline[liftpen=2](0,0)(!!CP)% draw from the UNTRANSLATED origin to the current point
    }       
}
\end{pspicture}

\end{document}

It produces two output as follows.

enter image description hereenter image description here

Objective

The red curve is made by concatenating unit tangent vectors

\pscustom[linecolor=red]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        \translate(!!CP)
        \lineto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
    }       
}

and the blue curve is not what I want to get.

\pscustom[linecolor=blue]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        \translate(!!CP)
        \moveto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
        \psline[liftpen=2](0,0)(!!CP)% draw from the UNTRANSLATED origin to the current point
    }       
}

The blue diagram should represent a set of radial lines emerging from the origin to the tip of the unit tangent vector.

Question

How to draw a line from the untranslated origin to the current point? In other words, how to draw a line from the absolute origin to the current point?

Note

Please just add code in the given place holder below.

\pscustom[linecolor=blue]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        % you can add code here
        \translate(!!CP)
        \moveto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
        %\psline[liftpen=2](0,0)(!!CP)% draw from the UNTRANSLATED origin to the current point
        % or you can add code here
    }       
}
share|improve this question

1 Answer 1

up vote 1 down vote accepted
+100

Using \translate(!!CP) you move the whole coordinate system around, so that (0,0) no longer refers to the same origin. You can write the whole part without using \translate, but with relative line and move operations (\rlineto and \rmoveto):

\documentclass[pstricks,border=12pt]{standalone}
\SpecialCoor
\usepackage{multido}
\begin{document}
\makeatletter
% draw the tangential lines
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=red]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        \rlineto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
    }       
}
\end{pspicture}

% draw the radial lines
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom[linecolor=blue]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        \rmoveto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
        \psline[liftpen=2](0,0)(!!CP)
    }       
}
\end{pspicture}
\makeatother
\end{document}

enter image description hereenter image description here

If it's only about ignoring the translations, then you can define the origin as a node. The nodes saves the current matrix, and restores the very same point regardless of the translations and scaling which have been done in the meanwhile:

\documentclass[pstricks,border=12pt]{standalone}
\SpecialCoor
\usepackage{multido}
\usepackage{pst-node}
\begin{document}
% draw the radial lines
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pnode(0,0){Origin}
\pscustom[linecolor=blue]
{
    \psline(1,0)
    \code{0 /Angle ED}
    \multido{\i=1+1}{15}
    {
        \translate(!!CP)
        \moveto(!1 Angle 1 \i\space 1 sub sqrt Atan add dup /Angle ED PtoC)
        \psline[liftpen=2](Origin)(!!CP)
    }       
}
\end{pspicture}
\end{document}
share|improve this answer
    
there is no need for a new translate, rotating does it anyway. –  Herbert Jan 21 at 12:12

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.