TikZ-PGF – Confusion Regarding + and ++ Symbols

tikz-pgf

I can't seem to figure out the difference between + and ++ relative coordinates in TikZ.

I understand ++. ++ specifies delta coordinates that are added to the last current point, the current point is then set to the new absolute current point (correct?):

\draw (0,0) -- ++(1,0) -- ++(0,1) means:

set Current Point to (0,0)
add (1,0) to Current Point = (1,0)
set Current Point to (1,0)
add Current Point (1,0) to (0,1) = (1,1)
set Current Point to (1,1)

I can't seem to figure out that + does, when I try it out it looks like the coordinates in the +(x,y) are absolute coordinates rather than delta coordinates, but the manual says otherwise

Best Answer

Your example:

\draw (0,0) -- ++(1,0) -- ++(0,1) means:

  • the current point is (0,0).
  • draw a line from the current point (0,0) to (0,0)+(1,0) (vector addition) and move the current point to (0,0)+(1,0).

  • next draw a line from the current point (0,0)+(1,0) to (0,0)+(1,0)+(0,1) and move the current point to (0,0)+(1,0)+(0,1).

Other examples are given as follows.

enter image description here

\documentclass[tikz,border=12pt]{standalone}

\begin{document}
\begin{tikzpicture}
    \draw (-2,-2) grid (2,2);
    \fill (110:2) circle (1pt);
    \draw (110:2) -- +(0,-1);
\end{tikzpicture}
\end{document}

Remarks for TikZ:

  • \draw (110:2) -- +(0,-1); The current point is (110:2). It draws a line from point (110:2) to point (110:2)+(0,-1) (vector addition). The current point is still at (110:2).

  • \draw (110:2) -- ++(0,-1); The current point is (110:2). It draws a line from point (110:2) to point (110:2)+(0,-1) (vector addition). The current point is moved to (110:2)+(0,-1).

  • \draw (110:2) +(0,-1) -- +(0,1); The current point is (110:2). It draws a line from point (110:2)+(0,-1) to point (110:2)+(0,1). The current point is still at (110:2).

  • \draw (110:2) ++(0,-1) -- +(0,1); The current point is (110:2)+(0,-1). It draws a line from point (110:2)+(0,-1) to point (110:2)+(0,-1)+(0,1). The current point is still at (110:2)+(0,-1).

  • \draw (110:2) ++(0,-1) -- ++(0,1); The current point is (110:2)+(0,-1). It draws a line from point (110:2)+(0,-1) to point (110:2)+(0,-1)+(0,1). The current point is moved to (110:2)+(0,-1)+(0,1) (which is equal to (110:2)).

Edit:

\draw (0,0) -- +(1,1) -- +(2,0) means

  • the current point is (0,0).

  • the first segment connecting (0,0) and (0,0)+(1,1).

  • the current point is still (0,0).

  • the second segment connecting the previous point (0,0)+(1,1) and (0,0)+(2,0).

The key is A -- B connects A and B with a line no matter how A and B are defined.