Text placed at distance from line, given radius and angle

Assume a line from A to B. At p% (or p mm/cm) of the distance from A to B, starting from A, I want to "turn" using a radius r and an angle y relative to the AB direction (y=0 is in the direction of the line AB, 90=90 degrees to the left of the direction of the line AB, etc.) and place a text there.

The following command,

\node at ($(A)!0.5!10:(B)$){x};


angles the 'x' 10 degree to the horizontal plane, around A (not at the 50% distance) with the radius 50% of the distance between A and B but I like to have a more general command where I can specify the radius and angle, relative to the line direction at p% of the line distance, starting from A. Is this possible? TIA! (I'm sorry for the confusing description/question!)

• This is what the last example in section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual v 3.1.4 does. – Schrödinger's cat Aug 19 at 19:38
• \documentclass[tikz]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \coordinate (a) at (1,0); \coordinate (b) at (3,1); \draw (a) -- (b); \path ($($ (a)!.5!(b) $)!1cm!90:(b)$) node{x}; \end{tikzpicture} \end{document} where .5 is the fraction, 1cm the radius and 90 the angle. You can adjust each of these as you like. – Schrödinger's cat Aug 19 at 19:42
• I don't understand your question. The calc library allows you to specify the radius and angle of rotation. What do you think is not enough when using this library? – AndréC Aug 20 at 6:13
• The calc library works fine, but I did not know of the nested method, described by Schrödinger's cat. I should really read the manual. My fault. – mf67 Aug 20 at 12:30

This is what the last example in section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual v 3.1.4 does. By nesting the calc syntax you can combine the directives used there to one.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (1,0);
\coordinate (b) at (3,1);
\draw (a) -- (b); \path ($($ (a)!.5!(b) $)!1cm!90:(b)$) node{x};
\end{tikzpicture}
\end{document}


If you want to use these things repeatedly, it may make sense to define a style in which the fraction, radius and angle are stored in pgf keys.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[between/.style args={#1 and #2}{/tikz/insert path={%
($($ (#1)!\pgfkeysvalueof{/tikz/mf67/fraction}!(#2)
$)!\pgfkeysvalueof{/tikz/mf67/radius}!\pgfkeysvalueof{/tikz/mf67/angle}:(#2)$)}},