I'd like to define the point C on line AB such that AC=k, using the calc library and the let... in... command. This does not work, why? Is there a unit problem (C seems to be pretty close to A)? I tried the scalar() function (pgfmanual 3.0.1A, p925) but it didn't help.
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate[label=above left:$A$](A) at(-2,-1);
\coordinate[label=above right:$B$](B) at (2.5,1);
\pgfmathsetmacro\k{3.0}
\path
let \p1=($(B)-(A)$),
\n1={veclen(\x1,\y1)}
in coordinate[label=below:$C$] (C) at ($(A)!{\k/\n1}!(B)$);
\foreach \p in {A,B,C}
\fill (\p) circle (1.5pt);
\end{tikzpicture}
\end{document}
Thank you!
C
should be? Ar you sure, that calculation of coordinateC
position is correct?\coordinate[label=below:$C$] (C) at ($(A)!3cm!(B)$);
or\coordinate[label=below:$C$] (C) at ($(A)!\k cm!(B)$);
.\n1
is given in points (in your case it is140.1146pt
. So you first need to make both variable to be in the same length units.