# tikz: name the endpoint of a path

I have a simple tikzsketch that draws a vector relative to the center of a triangle and perpendicular to one of it's edges.

I would like to draw another path (vector) at the tip of the blue arrow in my sketch. I figure what I want to do is name the coordinate at the end of the path, but am not sure about the syntax of how to do that.

How do I capture / name a coordinate in a calculated path?

\documentclass[border=20pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{intersections, calc,through,backgrounds}

\begin{document}

\begin{tikzpicture}[scale=2]

% Coordinates for a triangle
\coordinate (P) at ($(0,0) + (rand,rand)$);
\coordinate (Q) at ($(2,-2) + .5*(rand, rand)$);
\coordinate (R) at ($(-2, -2) + .5*(rand, rand)$);

\coordinate (O) at (barycentric cs:P=1,Q=1,R=1) ;

%projection of O on PQ
%use this for the intersection point for the vector below
\coordinate (E) at ($(P)!(O)!(Q)$);

% Vector perpendicular to edge PQ and located at O
% I would like to get the coordinate at the tip of this vector
\draw[->, blue] let
\p1 = ($(P)-(Q)$)
in
(O)--node[midway, sloped, above]{$\vec{A}$}node[above,at end]{${\color{black}S}$}++($(O)!sqrt(\x1*\x1+\y1*\y1)!(E)-(O)$);

%\fill[red](S)circle(2pt)

\draw[thin] (P) -- (Q) -- (R) --cycle;
\end{tikzpicture}
\end{document}

• the answer below may point you in the right direction – js bibra Feb 14 at 8:45

In the following line:
(O)--node[midway, sloped, above]{$\vec{A}$}node[above,at end]{${\color{black}S}$}++($(O)!sqrt(\x1*\x1+\y1*\y1)!(E)-(O)$);
you can add coordinate[at end](S) right before drawing your point S.

Then you get :
(O)--node[midway, sloped, above]{$\vec{A}$} coordinate[at end](S) node[above,at end]{${\color{black}S}$}++($(O)!sqrt(\x1*\x1+\y1*\y1)!(E)-(O)$);

\documentclass[border=20pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{intersections, calc,through,backgrounds}

\begin{document}

\begin{tikzpicture}[scale=2]

% Coordinates for a triangle
\coordinate (P) at ($(0,0) + (rand,rand)$);
\coordinate (Q) at ($(2,-2) + .5*(rand, rand)$);
\coordinate (R) at ($(-2, -2) + .5*(rand, rand)$);

\coordinate (O) at (barycentric cs:P=1,Q=1,R=1) ;

%projection of O on PQ
%use this for the intersection point for the vector below
\coordinate (E) at ($(P)!(O)!(Q)$);

% Vector perpendicular to edge PQ and located at O
% I would like to get the coordinate at the tip of this vector
\draw[->, blue] let
\p1 = ($(P)-(Q)$)
in
(O)--
node[midway, sloped, above]{$\vec{A}$}
coordinate[at end, label=aux, fill=red, circle, inner sep=0.5pt ]
++(
$(O)!sqrt(\x1*\x1+\y1*\y1)!(E)-(O)$
);

%        \fill[red](aux)circle(2pt)

\draw[thin] (P) -- (Q) -- (R) --cycle;
\end{tikzpicture}
\end{document}