# TikZ smooth plot, retrieves points along the path in parametric way

Suppose I have a certain curve, whose "control" points I specify using pre-set coordinates.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,calc,arrows,decorations.pathmorphing,intersections}

\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (42,0);
\coordinate (C) at (0,42);
\draw plot[smooth] coordinates{(A) (B) (C)};
\end{tikzpicture}
\end{document}


Now we can imagine that this is some trajectory and some "object" has been at coordinate (A) at time t = 0 and has arrived at (C) at time t = 1. I would like to know if it is possible to specify a certain spot along this trajectory, saying t = 0.5 for example, that would effectively mean "halfway through" (A) and (B)? I need this functionality so that I can specify a "naturally-looking" shape, and only then draw things on it.

This can be done using path decorations:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}[
define coord/.style 2 args={
decoration={
markings,
mark=at position #2 with {\coordinate (#1);},
},
postaction=decorate,
}
]
\coordinate (A) at (0,0);
\coordinate (B) at (5,0);
\coordinate (C) at (0,5);
\draw[blue, define coord={P}{0.2}, define coord={I}{0.5},
define coord={Q}{0.75}]
plot[smooth] coordinates { (A) (B) (C) };
\fill[red] (P) circle[radius=2pt] node[black, below] {At time $0.2$};
\node[red!80!black, pin=20:$I$] at (I) {middle};
\node[above right] at (Q) {At $3/4$ of the curve};
\end{tikzpicture}
\end{document}


As you noted, in a given path, the style must be used with increasing coordinates, otherwise the points aren't placed as expected.

• I accept the answer. The only caveat is that the ratios need to be specified in increasing order, otherwise the engine gets somehow confused. – Ilonpilaaja Oct 2 '20 at 6:37
• @Ilonpilaaja You're right, thanks for pointing it out. I've slightly expanded the example and mentioned the “increasing order” constraint for coordinates. – frougon Oct 2 '20 at 8:47