# Normal and tangent vector at specific absolute rather than relative point

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}


• if you know where it is then you can just place it no? Feb 26, 2016 at 4:34
• In the case of an elliptic curve, I could do the math, of course. However, a solution for arbitrary curves would be nice Feb 26, 2016 at 8:47

Using the tzplot package:

\documentclass[tikz]{standalone}

\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}[font=\scriptsize]
\tzhelplines(7,6)
\tzaxes(7,6)
\tzcoor(40:3 and 5)(P)
\tzcoor($1.5*(P)$)(P2)
\tzarcfrom[gray]"arcA"(-10:3 and 5)(-10:95:3 and 5)
\tzline[->,green](0,0)(P)
\tzline[dashed,green](P)(P2)
\tztangent[blue!20,thin]"tan"{arcA}(P)[1:3.5]{tangent}[r]
\tzhXpointat{tan}{2}(P3a)        % (P3a): point on tangent line
\tzcoor($(P)!1cm!90:(P3a)$)(P3)  % (P3) : point on normal  line
\tzgetxyval(P){\Px}{\Py}
\tzslopeat[->,green,tzextend={0pt}{2cm}]{arcA}{\Px}{.1pt}[90]
\tzanglemark[->,green](P2)(P)(P3){$\rho$}[green]
\tzrightanglemark(P3)(P)(P3a)
\tzanglemark(P)(0,0)(1,0){$\theta$}
\end{tikzpicture}

\end{document}