   

\newcommand{\DrawCurve}[2]
{
   %cos and sin expects degrees: deg(\t)
   %Alternative: tikzpicture option trig format=rad
   \draw[curves,#2]
       plot
       (
           { \r*(  \t-#1*sin(deg(\t))  ) },
           { \r*(  1 -#1*cos(deg(\t))  ) }
       );
}

%CalcFrenet point: store in (T) and (N)
%Parameters: #1: lambda, #2: t
\newcommand{\CalcFrenet}[2]
{
   \CalcDr{#1}{#2}
   \CalcV{#1}{#2}
   \pgfmathparse{1/\v} \let\f\pgfmathresult
   
   \coordinate (T) at ($\f*(dR)$);
   \coordinate (N) at ($\f*(dRHat)$);
}

%DrawFrenet system
%Parameters: #1: lambda, #2: t
\newcommand{\DrawFrenet}[3]
{
   \CalcR{#1}{#2}
   \CalcFrenet{#1}{#2}
   
   \draw[frenet,-latex] #3 -- +(T);
   \draw[frenet,-latex] #3 -- +(N);
   
   \node[frenet] at ($#3+1.1*(T)$) {$\underline{t}$};
   \node[frenet] at ($#3+1.1*(N)$) {$\underline{n}$};
}

%DrawTaylorI: Draw first order Taylor info
%Parameters: #1: lambda, #2: t0, #3: t
\newcommand{\DrawTaylorI}[3]
{
    %Calculate second trochoid point
    \CalcR{#1}{#2}
    \coordinate (RR) at (R);
    \filldraw[curves] (RR) circle(1pt) node[right] {$t$};;
    
    \pgfmathparse{#3-#2} \let\Eps\pgfmathresult
    \CalcR{#1}{#2} 
    \CalcDr{#1}{#2} 
    
    \coordinate (Delta1) at ($\Eps*(dR)$);
    \draw[-latex] (R) -- +(Delta1);
    \filldraw[] ($(R)+(Delta1)$)
       circle(1pt) 
       node[right] {\tiny{$(t-t_0) \underline{r}_0'$}};    
}

%DrawTaylorI: Draw second order Taylor info
%Parameters: #1: lambda, #2: t0, #3: t
\newcommand{\DrawTaylorII}[3]
{
    \pgfmathparse{#3-#2} \let\Eps\pgfmathresult
    
    \DrawTaylorI{#1}{#2}{#3} 
    \CalcDDr{#1}{#2} 
    
    \coordinate (Delta2) at ($0.5*\Eps*\Eps*(ddR)$);
    \coordinate (P1) at ($(R)+(Delta1)$);
    \coordinate (P2) at ($(R)+(Delta2)$);
    \coordinate (P) at ($(R)+(Delta1)+(Delta2)$);
    
    \draw[-latex] (R) -- (P2);
    \draw[dashed] (P1) -- (P) -- (P2); 
    
    \filldraw (P2) circle (1pt) node[left]
       {\tiny{$\frac{1}{2} (t-t_0)^2\underline{r}_0''$}};
       
    \draw[-latex,dotted] (R) -- (P);
    \filldraw[-latex,dotted] (P) circle (1pt);
    \CalcR{#1}{#3} 
    \filldraw[curves,-latex,dotted] (R) circle (1pt);
    \draw[error] (R) -- (P);
    \draw[error] (0,0) -- ($(P)-(R)$);
    \node[curves] at ($(R)!1.05!(P)$) {$t$};;
}

