I would like to draw a normal vector on a curve at a specific point. I looked up several questions (e.g. 1, 2, 3, etc) and the answers contain nice solutions for drawing a tangent or normal vector to a curve at a given point which is specified by a variable between 0 and 1 giving the distance moved on the curve.
Another example uses absolute distances, but that coordinate still "travels" along the curve.
I, however, have several curves where I know a point's absolute coordinates (relative to the picture's coordinate system) but not exactly, where it sits on that curve in that relative coordinate.
I the following (not minimal, but working) example, I use the very useful code from this answer and find by trial and error, that the relative coordinate of my point P is roughly 0.5573. As I will use this for different types of curves and different points, trying out is very tedious. Is there a nice solution with absolute coordinates?
\documentclass[]{scrartcl}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,calc,positioning,decorations,decorations.markings,quotes,angles}
\tikzset{tangent/.style={
decoration={
markings,% switch on 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}
\begin{document}
\begin{tikzpicture}[%baseline={([yshift=-.0ex]current bounding box.center)},
kvect/.style={->,>=stealth}]
% coordinates
\coordinate(O) at (0,0);
\coordinate(OAend) at (90:5.5);
\coordinate(OAstart) at (-90:.5);
\coordinate(X1) at (180:.5);
\coordinate(X2) at (0:3.5);
\coordinate(P) at (40:3cm and 5cm);
\coordinate(P2) at ($1.5*(P)$);
\coordinate(ARCSTART) at (-10:3cm and 5cm);
% curve
\draw[tangent=0.5573,color=darkgray] (ARCSTART) arc (-10:95:3cm and 5cm);
% other lines
\path[kvect] (OAstart) edge (OAend); % optical axis
\path[kvect] (X1) edge (X2);
\path[kvect,color=green] (O) edge (P);
\path[dashed,color=green] (P) edge (P2);
\path [kvect,color=green, use tangent](0,0) edge (0,-3) [] {};
\path [use tangent](0,0) -- (0,-3) node (Sp) [] {};
\path pic["$\rho$",angle eccentricity=1.5,angle radius=0.6cm,draw,<-,>=stealth,color=green] {angle = Sp--P--P2};
\path pic["$\theta$",angle eccentricity=1.5,angle radius=0.6cm,draw] {angle = P--O--OAend};
\end{tikzpicture}
\end{document}