# Drawing two vectors at a precise point of a curve

I have drawn the following figure.

\documentclass[a4paper, 11pt]{book}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\makeatletter
\newcommand{\gettikzxy}{%
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}%
\edef#3{\the\pgf@y}%
}
\makeatother

\begin{center}

\begin{tikzpicture}
\draw[gray, thick] (0,0) to [bend left=20]  coordinate[pos=0.15](A)(7,2);
\filldraw[black] coordinate[pos=1] (B)(7,2) circle (1.5pt);
\draw[thick,gray] (A) to [bend right = 10] (7,2);
\gettikzxy{(A)}{\ax}{\ay}
\gettikzxy{(B)}{\bx}{\by}
\fill[black] (\ax, \ay) circle (1.5pt) node[anchor = east]{$\sigma(\epsilon)$};
\fill[black] (\bx, \by) circle (1.5pt) node[anchor = east]{$p$};
\fill[black] (7,2) circle (1.5pt) node[anchor = west]{$q$};

\draw (3.6,1.8) node[anchor = south]{$\sigma$};
\draw (4,1) node[anchor = south]{$\delta$};
\end{tikzpicture}

\end{center}


Here is the image. Now I would like to add two vectors at the point $\sigma(\epsilon)$, one tangent to the curve $\sigma$ and the other one tangent to the curve $\delta$.

Thank you very much!

• Jul 8, 2016 at 10:12
• @Ignasi - I don't think it's quite a duplicate, because OP wants the tangent at delta drawn at sigma (at least I think that's what the question asks). In Metapost you could just use rotated angle direction t of curve to get the desired angle, but I don't see how you can do that with a Tikzy decoration approach. Jul 8, 2016 at 10:44
• @Thruston I don't say it's a duplicate, but a related question which, may be, it's worth to read. Jul 8, 2016 at 11:48
• @Ignasi - fair enough! Jul 8, 2016 at 11:49
• I'm trying to "play" with the codes I found in the links.. but I am not getting anything good so far. I am very new to the package Tikz. I've discovered it just yesterday.. Anyhow thank you for the links! Jul 8, 2016 at 11:51

I found a solution playing a bit with the codes I found in the answer at this question, as it was suggested in the comments.

I do not have any idea why and how the code does work, but still the result is exactly what I was looking for. I want to share with you the code because maybe it will be useful for some other people one day.

\documentclass[a4paper, 11pt]{book}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\makeatletter
\newcommand{\gettikzxy}{%
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}%
\edef#3{\the\pgf@y}%
}
\makeatother

\begin{document}
\begin{center}

\begin{tikzpicture}
\draw[gray, thick] (0,0) to [bend left=20]node[sloped,inner sep=0cm,above,pos=.15,
anchor=south west,
minimum height=(10.5)*0.3cm,minimum width=(10.5)*.3cm](N){}  coordinate[pos=0.15,sloped,inner sep=0cm,below,
anchor=south west,
minimum height=3cm, minimum  width=2cm] (A)(8,2);

\path (N.south west)
edge[-stealth',black] node[above] {$\dot{\sigma}(\epsilon)$} (N.south east);

\filldraw[black] coordinate[pos=1] (B)(8,2) circle (1.5pt);
\draw[thick,gray] (A) to[bend right = 15] node[sloped,inner sep=0cm,above,pos=0,
anchor=south west,
minimum height=(10.5)*0.3cm,minimum width=(10.5)*.3cm](C){}  (8,2);

\path (C.south west)
edge[-stealth',black] node[below] {$\dot{\delta}(0)$} (C.south east);

\gettikzxy{(A)}{\ax}{\ay}
\gettikzxy{(B)}{\bx}{\by}
\fill[black] (\ax, \ay) circle (1.5pt) node[anchor = east]{$\sigma(\epsilon) = \delta(0)$};
\fill[black] (\bx, \by) circle (1.5pt) node[anchor = east]{$p$};
\fill[black] (8,2) circle (1.5pt) node[anchor = west]{$q$};

\draw (5,2) node[anchor = south]{$\sigma$};
\draw (5.5,1) node[anchor = south]{$\delta$};
\end{tikzpicture}

\end{center}

\end{document}


Here is the picture of the result. • where is defined \gettikzxy, \ax, ay, ... your example I can't compile. do I miss something? Jul 8, 2016 at 12:44
• ah yeah! sorry! it is incomplete! I will edit in few seconds Jul 8, 2016 at 12:49
• Now it should work! Jul 8, 2016 at 12:52
• now it works! (+1) for nice solution :-) Jul 8, 2016 at 13:11

It can be done with a decoration but not the markings decoration as that will prove to be too inaccurate. Instead, the show path construction decoration can be used in combination with the basic layer \pgftransformcurveattime command. It isn't strictly necessary to access the internal segment points from the decoration engine, but it is less verbose.

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\makeatletter
\tikzset{mark curve vector/.style args={at (#1) with #2}{
postaction={decorate, decoration={show path construction,
curveto code={\pgfslopedattimetrue\pgfallowupsidedownattimetrue%
\pgftransformcurveattime{#1}{\pgf@decorate@inputsegment@first}%
{\pgf@decorate@inputsegment@supporta}%
{\pgf@decorate@inputsegment@supportb}%
{\pgf@decorate@inputsegment@last}%
#2}}}}}
\begin{document}
\begin{tikzpicture}
\draw [draw=gray, thick, mark curve vector=at (0.15) with {
\draw [black, -stealth, thin] coordinate (A) (0,0) -- (2,0)
node [midway, above left] {$\dot\sigma(\epsilon)$};
}]
(0,0) coordinate (p) to [bend left=20]
node [pos=2/3, above] {$\sigma$} (7,2) coordinate (q);

\draw [draw=gray, thick, mark curve vector=at (0) with {
\draw [black, -stealth, thin]  (0,0) -- (2,0)
node [midway, below] {$\dot\delta(0)$};
}] (A) to [bend right=15] node [pos=2/3, above] {$\delta$} (q);

\fill (p) circle [radius=0.05] node [left] {$p$};
\fill (q) circle [radius=0.05] node [right] {$q$};
\fill (A) circle [radius=0.05] node [above left]
{$\sigma(\epsilon)=\delta(0)$};
\end{tikzpicture}
\end{document} 