# Draw a curve in TikZ with hairs growing on one side

I would like to be able to draw tikz pictures that generalize the following one:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) to (1,0);
\foreach \n in {.1,.2,...,.9} \draw (\n,0) to (\n,.1);
\end{tikzpicture}
\end{document}


The result of the above code is a horizontal line with short "hairs" growing off one side, perpendicular to the curve. I want to achieve this effect but for curves that bend in customized ways, for example by specifying a number of points they pass through along with in and out angles at each one. In that case, I can't just repeat the above strategy, since the exact endpoints of the hairs are determined in a complicated way by the points and in/out angles used to define the curve. Any ideas?

Shamelessly using this great tangent line answer to sort out your problem. Try the following code:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}[
tangent/.style={decoration={markings,mark=at position #1 with {
\coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
\coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
\coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
}},postaction=decorate},
use tangent/.style={
shift=(tangent point-#1),
x=(tangent unit vector-#1),
y=(tangent orthogonal unit vector-#1)
},
use tangent/.default=1
]
% Define your path here
\def\PTH{(0,0) to [out=20,in=120] (5,2) to [out=-60, in=110] (9,1)}
% Choose the number of "hairs" here
\def\tans{30}
\draw \PTH;
\foreach \x in {1,...,\tans}{
\path[tangent=\x/\tans] \PTH;
\draw [blue, thick, use tangent=1] (0,0) -- (0,.5);
}
\end{tikzpicture}
\end{document}


This should give you the following picture:

Note that you can change the length of the "hairs," which are now set to 0.5 in the foreach loop. Also, if you change the endpoint of the "hairs" to be (.5,0) instead, then you will get short hairs that are tangent to the path.