Tikz: `\tikztostart`, how to differentiate nodes from coordinates, and obtain coordinate at angle X of node’s border

tikz-pgf

I'm curious to know, how can I choose the starting point of a path? I'm trying to produce this kind of pictures when my user draws a path from A to B:

enter image description here

However, if I use (\tikztostart.west) to specify that the path should start on the west part, then if the users can't anymore do \path (A.center) to[myC] (B.center) to force the node to start at center (I guess it evaluates to A.center.west which does not exist).

Any idea how to make it work? Also, I'm quite curious: in some libraries like when using in=40, they manage to start from the boundary of the node at an arbitrary angle… How is it possible to obtain programmatically this coordinate? [EDIT Seems like \pgfpointshapeborder{}{} can be useful to do that? TODO: read more in "The basic layer" part of the manual ]

BONUS: why can't I do \ifnum\y2>0?

MWE

\documentclass[]{article}

\usepackage{tikz-cd}
\usetikzlibrary{calc}

\begin{document}
Problem: need to specify \verb|.west|:
\begin{tikzcd}[
  myC/.style={
    to path={ let \p1=(\tikztostart|-\tikztotarget), \p2=($(\p1)-(\tikztostart)$), \n1={veclen(\x2,\y2)} in arc[start angle=180+90,end angle=90,radius=\n1/2] -- (\tikztotarget) \tikztonodes}
  },
  ]
  |[]|                       & |[alias=B,draw,circle]| B\\
  |[alias=A,circle,draw]|A   & |[alias=C,draw,circle]| C
  \arrow[-,from=A.west,to=B.west,myC]
  \arrow[-,from=C.west,to=B.west,myC]
\end{tikzcd}

Problem: can't force start at center.
\begin{tikzcd}[
  myC/.style={
    to path={ (\tikztostart.west) let \p1=(\tikztostart.west|-\tikztotarget.west), \p2=($(\p1)-(\tikztostart.west)$), \n1={veclen(\x2,\y2)} in arc[start angle=180+90,end angle=90,radius=\n1/2] -- (\tikztotarget.west) \tikztonodes}
  },
  ]
  |[]|                       &                           & |[alias=B,draw,circle]| B\\
  |[alias=A,circle,draw]|A   & |[alias=C,draw,circle]| C
  \arrow[-,from=A,to=B,myC]
  % this fails:
  %\arrow[-,from=C.center,to=B,myC]
\end{tikzcd}

Bonus: how to make \verb|\ifnum\y2>0| work?
% \begin{tikzcd}[
%   myC/.style={
%     to path={ let \p1=(\tikztostart|-\tikztotarget), \p2=($(\p1)-(\tikztostart)$), \n1={veclen(\x2,\y2)} in \ifnum\y2>0 \abc>0 arc[start angle=180+90,end angle=90,radius=\n1/2] \else arc[start angle=90,end angle=180+90,radius=\n1/2] \fi -- (\tikztotarget) \tikztonodes}
%   },
%   ]
%   |[]|                       & |[alias=B,draw,circle]| B\\
%   |[alias=A,circle,draw]|A   & |[alias=C,draw,circle]| C
%   \arrow[-,from=A.west,to=B.west,myC]
%   \arrow[-,from=B.west,to=C.west,myC]
% \end{tikzcd}

\end{document}

EDIT
I managed to do the bonus part using \pgfextra{\pgfmathparse{\y2>0}}\ifnum\pgfmathresult=1 ... \else ... \fi:

\begin{tikzcd}[
  myC/.style={
    to path={ let \p1=(\tikztostart|-\tikztotarget), \p2=($(\p1)-(\tikztostart)$), \n1={veclen(\x2,\y2)} in \pgfextra{\pgfmathparse{\y2>0}}\ifnum\pgfmathresult=1 arc[start angle=180+90,end angle=90,radius=\n1/2] \else arc[start angle=90,end angle=180+90,radius=\n1/2] \fi -- (\tikztotarget) \tikztonodes}
  },
  ]
  |[]|                       & |[alias=B,draw,circle]| B\\
  |[alias=A,circle,draw]|A   & |[alias=C,draw,circle]| C
  \arrow[-,from=A.west,to=B.west,myC]
  \arrow[-,from=B.west,to=C.west,myC]
\end{tikzcd}

But the initial question is still open.

EDIT 2

After inspecting the source code of tikz, I found out that the \iftikz@shapeborder allows to do something like that… but unfortunately I think it does not work with \tikztotarget since it does not take any argument… Any idea how to check that information for both the input and output?

Best Answer

It is very simple, both the figure and the code.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\a{1.5} 
\path[nodes={circle,draw,minimum size=6mm}]
(0,0)   node (A) {$A$}  
(\a,\a) node (B) {$B$}
(\a,0)  node (C) {$C$}
;
\draw[->] (B.west) --+(180:\a) arc(90:270:\a/2);
\draw[->] (B.west) arc(90:270:\a/2);
\end{tikzpicture}
\end{document}