12

enter image description here

\documentclass[pstricks,border=20pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}(3,3)
   \pstGeonode(0,0){A}(3,3){B}
   \pnode([nodesep=10pt]{B}A){A'}
   \pnode([nodesep=10pt]{A}B){B'}
   \psline(A)(A')
   \psline[linestyle=dashed,linecolor=red](A')(B')
   \psline(B')(B)
\end{pspicture}
\end{document}

What is the equivalent for ([nodesep=10pt]{B}A) in TikZ? In PSTricks it represents a point that is 10pt apart from A and on a line joining A and B.

1 Answer 1

14

You can use ($(A)!1cm!(B)$) to move a specific distance along the path as shown in the second image. The first image is the more usual usage to move a certain percentage along the line:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
    \coordinate (A) at (0,4);
    \coordinate (B) at (3,6);
    \draw [thin, blue] (A) -- (B);
    \node [below] at (A) {A};
    \node [above] at (B) {B};

    
    \coordinate (A') at ($(A)!0.25!(B)$);
    \draw [ultra thick, red] (A) -- (A') node [above left,black] {(\$(A)!0.25!(B)\$)};
\end{tikzpicture}
\begin{tikzpicture}
    \coordinate (A) at (0,4);
    \coordinate (B) at (3,6);
    \draw [thin, blue] (A) -- (B);
    \node [below] at (A) {A};
    \node [above] at (B) {B};
    
    \coordinate (A') at ($(A)!1cm!(B)$);
    \draw [ultra thick, red] (A) -- (A') node [below right,black] {(\$(A)!1cm!(B)\$)};
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .