2

thanks for taking the time. I have the problem, that I want to get normal vectors on a smooth plot, furthermore I have lines intersecting said plot, but they also need to end in the graph. My approach so far is using the decorations for the normal vectors. I need to create the next normal vector at the intersection of $A$ with the boundary, and I'd like to cut $A$ short at exactly the intersection.

  \begin{tikzpicture}[
decoration={
markings,
mark=at position 0.4 with {\draw[->] (0,0)--(0,1);},
mark=at position 0.4 with {\draw[->] (0,0)--(2,-2) node[below]{A};},
mark=at position 0.4 with {\draw[<-] (0,0)--(-.8,-.8);}
}
]
\draw[postaction={decorate}] plot [smooth cycle] coordinates {(0,0) (1,1) (3,1) (3,0) (2,-1)};
\end{tikzpicture}

I hope my problem has a solution. Thanks in advance. Fabian

Fabian
  • 45

1 Answers1

2

Welcome to TeX.SE! You can add arbitrarily many commands to one draw command.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[
decoration={
markings,
mark=at position 0.4 with {\draw[->] (0,0)--(0,1);
\draw[->] (0,0)--(2,-2) node[below]{A};
\draw[<-] (0,0)--(-.8,-.8);}
}
]
\draw[postaction={decorate}] plot [smooth cycle] coordinates {(0,0) (1,1) (3,1) (3,0) (2,-1)};
\end{tikzpicture}
\end{document}

enter image description here

What is more more, you can name the coordinates used in markings, and access it from outside.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[
decoration={
markings,
mark=at position 0.4 with {\draw[->] (0,0)coordinate(X) --(0,1);},
}]
\draw[postaction={decorate}] plot [smooth cycle] coordinates {(0,0) (1,1) (3,1) (3,0) (2,-1)};
\draw[-latex] (1.5,-1.5) -- (X);
\draw[-latex] (X) -- (2,2);
\end{tikzpicture}
\end{document}

enter image description here

  • That helped quite a bit. I have one follow up question though. How can i find out the position of the intersection in relation to the decoration to get a second normal vector going? My only choice at this moment is trying to see the right point. Thanks again. – Fabian Nov 22 '18 at 09:34
  • @Fabian I have trouble interpreting this follow-up question. at position 0.4 means at 40% of the total length of the path. Could you please try to reword it? (BTW, by the rules of this site, follow-up questions are to be asked in form of a new question. Asking questions is free, after all.) –  Nov 22 '18 at 16:45
  • Thanks for the advice, here is the followup question written out: https://tex.stackexchange.com/questions/461379/finding-an-intersection-with-respect-to-the-decoration – Fabian Nov 23 '18 at 08:31