# Add “tangential nodes” to a hobby curve

Is it possible to place nodes along a hobby curve such that the orientation is tangential to the curve. I should add what I mean with tangential: The curved hobby path should represent a curvy street and then I would add an image of a car at a given position on the path such that the car points tangential to the curve. I tried to make it more clear with the following pseudo-code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{hobby}
\usepackage{graphicx}

\begin{document}
\begin{tikzpicture}
\draw
(0,0) to[out angle=0,in angle=180,curve through={(1,.9) ..node[rotation=tangential,pos=0.4]{\includegraphics[width=0.5cm]{car}} (2,0) .. (3,.5)}] (4,0);
\end{tikzpicture}
\end{document}


Take for example this car picture:

-
Where do you have this nice picture of a car from? –  moose Dec 19 '13 at 16:42
I asked google for "car top view". Then you find for example this: 4vector.com/free-vector/red-racing-car-top-view-99252 or this clker.com/clipart-red-car-top-view-11.html –  student Dec 19 '13 at 17:45
What a nice website. Thanks for sharing! –  moose Dec 19 '13 at 18:53

Loath as I am to admit it, but there's nothing particular to hobby here. The decorations libraries allow you to do this: they work along a curve without regard for how it was generated (so it can be generated by Hobby's algorithm) and "do stuff" as they go. When they do whatever it is that they do then they are in a coordinate frame where x points tangential to the curve and y is normal. Thus:

\documentclass{article}
%\url{http://tex.stackexchange.com/q/81812/86}
\usepackage{tikz}
\usetikzlibrary{hobby,decorations.markings}
\usepackage{graphicx}

\begin{document}
\begin{tikzpicture}
\draw[
postaction={
decorate,
decoration={
markings,
mark=at position 0.4 with
{
\draw[->,ultra thick,green] (-1,0) -- (1,0);
}
}
}
]
(0,0) to[out angle=0,in angle=180,curve through={(1,.9) .. (2,0) .. (3,.5)}] (4,0);
\end{tikzpicture}
\end{document}


(Sorry, not good at drawing cars.)

If the marking contains a node then you will want to use the transform shape key if you want to ensure that the node rotates to fit the tangential coordinate system (recall that nodes tend not to obey all the surrounding transformations unless explicitly told to do so).

With the graphic from the question saved as car.png:

\documentclass{standalone}
%\url{http://tex.stackexchange.com/q/81812/86}
\usepackage{tikz}
\usetikzlibrary{hobby,decorations.markings}
\usepackage{graphicx}

\begin{document}
\begin{tikzpicture}
\draw[
postaction={
decorate,
decoration={
markings,
mark=between positions 0 and 1 step 0.2 with
{
\node[transform shape] {\includegraphics[width=.5cm]{car}};
}
}
}
]
(0,0) to[out angle=0,in angle=180,curve through={(1,.9) .. (2,0) .. (3,.5)}] (4,0);
\end{tikzpicture}
\end{document}


-