# Behavior of dot operator in node relative placement

In placing a new node using relative positioning, what is the behavior of the dot operator when referring to an existing named node? For example, if xc is an existing named node, what does the following mean?

\path (xc.71) +(1,0) node (xd) {$x_4$};

Here's a short example (with such an occurrence) that draws a simple directed chain:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}

\begin{tikzpicture}[auto,scale=1.0,%
block/.style = {draw,circle,very thick,minimum size=0.5cm},%
directed/.style ={draw,-triangle 45, shorten >= 0pt, very thick}]

\pgfmathsetmacro{\strch}{1.2}

\path (0*\strch,0) node[block] (xa) {$x_1$}
(1*\strch,0) node[block] (xb) {$x_2$}
(2*\strch,0) node[block] (xc) {$x_3$};
\path (xa) [directed] -- (xb);
\path (xb) [directed] -- (xc);

\path (xc.71) +(\strch,0) node (threedots) {$\ldots$};

\path (threedots) +(\strch,0) node[block] (xn) {$x_n$};
\path (xc) [directed] -- (threedots);
\path (threedots) [directed] -- (xn);

\end{tikzpicture}
\end{document}


Changing the node reference to (xc.11) or (xc.999) or (xc.0), of course, yields different results, but it isn't clear to me after scouring the PGF manual what exactly the bit after the decimal means.

(FWIW, this question arose out of erroneously referring to a node x3 using a macro that stored the value of 3.0 instead of 3, hence x3.0. I've since fixed that bug, but I'm now just generally curious about this behavior.)

-
Short answer is that (a.b) means b anchor of shape a if b is found in the anchor list and point on the border of shape a with angle b with respect to center of a if b is a number. –  percusse Aug 7 '12 at 18:14
Thanks, @percusse, that makes perfect sense. I think the relative placement was obfuscating, for me, where the node anchor was being placed. –  Dan Levine Aug 7 '12 at 18:51
I'll dig up the relevant @ crowded definition and make a little more explanatory answer when I have the chance instead of the terrible English comment :) –  percusse Aug 7 '12 at 18:57
Here's an explanation I wrote for a similar situation: tex.stackexchange.com/a/28242/86 –  Loop Space Aug 7 '12 at 19:58

Here is the ruthless TikZ machinery for point scanning in action:

\def\tikz@@scan@@no@calculator#1(#2){% This receives the actual coordinate input.
% #1 and #2 are irrelevant for now
\pgfutil@in@{cs:}{#2}%             %Checks if cs syntax is present
\ifpgfutil@in@%                    % Yes no?
\let\@next\tikz@parse@coordinatesystem% Send it to the coordinate system parser
\else%
\pgfutil@in@{intersection }{#2}% % any intersections?
\ifpgfutil@in@%                  % Yes no?
\let\@next\tikz@parse@intersection% Send it....
\else%
\pgfutil@in@|{#2}%             % Check if |- or -| is used
\ifpgfutil@in@                 %
\pgfutil@in@{-|}{#2}%        %
\ifpgfutil@in@
\let\@next\tikz@parse@hv%
\else%
\let\@next\tikz@parse@vh%
\fi%
\else%
\pgfutil@in@:{#2}%           % Check if a polar input such as (45:1cm) is given
\ifpgfutil@in@               %
\let\@next\tikz@parse@polar%
\else%
\pgfutil@in@,{#2}%         % Finally check if (a,b) is given
\ifpgfutil@in@%
\let\@next\tikz@parse@regular% REGULAR
\else%
\let\@next\tikz@parse@node% Then it should be a node name,
% send it to node dept.
\fi%
\fi%
\fi%
\fi%
\fi%
\@next#1(#2)%
}


There is actually more to it but it boils down to this macro after ensuring that no \$ signs for calculations and a couple of things are not involved. So what does this do? Well, it's kind of tedious to go line by line so I have placed some comments in it for pointers. Basically, TikZ exhausts all the options it knows and then decides that the input is a named coordinate (or node but coordinate is also a special node) and calls further

\def\tikz@parse@node#1(#2){%
\pgfutil@in@.{#2}% Ok, flag this
\ifpgfutil@in@
\tikz@calc@anchor#2\tikz@stop%
\else%
\tikz@calc@anchor#2.center\tikz@stop% to be on the save side, in
% case iftikz@shapeborder is ignored...
\expandafter\ifx\csname pgf@sh@ns@#2\endcsname\tikz@coordinate@text%
\else
\tikz@shapebordertrue%
\def\tikz@shapeborder@name{#2}%
\fi%
\fi%
\edef\tikz@marshal{\noexpand#1{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
\tikz@marshal%
}

\def\tikz@calc@anchor#1.#2\tikz@stop{%
\pgfpointanchor{#1}{#2}%
}


You don't have to understand every bit (I don't study this thoroughly anyway) but the gist is important. It checks whether the name, say (c) belongs to a coordinate or not. If it is indeed a coordinate then it discards the remaining part of (c.30) since a coordinate is just a point and it has only one anchor. If not then (a.b) is interpreted as shape a with angle b. Then it checks whether a has a shape border or not. This is better explained in the manual but long story short, if the border shape is defined (as custom node shapes might not), TikZ draw a line from the center anchor with the given angle until it intersects with the shape border. Obviously if there is no such border, TikZ doesn't care like a boss. Here are the common shortcuts and the angles they represent:

\def\tikz@polar@dir@up{90}
\def\tikz@polar@dir@down{-90}
\def\tikz@polar@dir@left{180}
\def\tikz@polar@dir@right{0}
\def\tikz@polar@dir@north{90}
\def\tikz@polar@dir@south{-90}
\def\tikz@polar@dir@east{0}
\def\tikz@polar@dir@west{180}
\expandafter\def\csname tikz@polar@dir@north east\endcsname{45}
\expandafter\def\csname tikz@polar@dir@north west\endcsname{135}
\expandafter\def\csname tikz@polar@dir@south east\endcsname{-45}
\expandafter\def\csname tikz@polar@dir@south west\endcsname{-135}


Hence you can also use (a.south) etc. which is parsed similarly.

-
Getting expertise in @ jungle! –  Harish Kumar Aug 7 '12 at 23:47

(nodename.<number>) points to extern border line of node nodename with angle <number> (degrees).

So, (a 3.0) points to border line of node a 3 with angle 0 degree.

Examples:

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node[draw=orange,font=\huge,line width=3pt,inner sep=10pt] (A) {A};
\draw[->,green!50!black] (A.center) -- ++(20:5mm);
\foreach \angle in {0,20,...,340}{
node[font=\tiny,rotate=\angle,right]{A.\angle};
}

\node[draw=orange,circle,font=\huge,line width=3pt,inner sep=10pt]
(C) at (0,-3.5) {C};
\draw[->,green!50!black] (C.center) -- ++(20:5mm);
\foreach \angle in {0,20,...,340}{
node[font=\tiny,rotate=\angle,right]{C.\angle};
}

\node[draw=orange,ellipse,font=\huge,line width=3pt,inner sep=10pt]
(E) at (0,-7) {--- E ---};
\draw[->,green!50!black] (E.center) -- ++(20:10mm);
\foreach \angle in {0,20,...,340}{
node[font=\tiny,rotate=\angle,right]{E.\angle};
}

\node[draw=orange,trapezium,font=\huge,line width=3pt,inner sep=10pt]
(T) at (0,-10.5) {--- T ---};
\draw[->,green!50!black] (T.center) -- ++(20:10mm);
\foreach \angle in {0,20,...,340}{