# Path to midpoint of other path

I would like to end a path at the midpoint of another path. My inclination has been to try and end the path at an offset equal to half the node distance from d.north, but any thing I seem to try will not compile. Here's what I have so far (the end goal being the 'No' path ending at 'HERE' )

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}
\begin{document}
\pagestyle{empty}

% Define block styles
\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};

% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- node [midway, left] {HERE} (d);

\path [line] (a.east) --node [above] {No}  +(1,0) |- (d.north);

\end{tikzpicture}

\end{document}


I've seen some things on path decorations, but I'm really unsure how to use them and not sure that I can end the path on them.

-

Your code already contains a solution (without calc library): midway!

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']

\begin{document}
\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};

% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- coordinate[midway](m) (d);

\path [line] (a.east) --node [above] {No}  +(1,0) |- (m);
\end{tikzpicture}
\end{document}


-
Ha! Simplicity above all. –  Gonzalo Medina Sep 4 '12 at 21:28
That's awesome. I think I'll switch to this because I know it'll be easier to read/relearn when I come back to these diagrams in a few months. –  blitzvergnugen Sep 5 '12 at 20:34
@blitzvergnugen Don't forget that midway is in fact pos=.5... –  Paul Gaborit Sep 5 '12 at 22:21

Like this? (c)!0.5!(d) means halfway between (c) and (d).

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}
\begin{document}
\pagestyle{empty}

% Define block styles
\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};

% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- node [midway, left] {HERE} (d);

\path[line] let \p1 = ( $(c)!0.5!(d)$ ) in (a.east) --node [above] {No}  +(1,0) |- +(0,\y1);

\end{tikzpicture}

\end{document}


-
That works great! I changed it to \path [line] (a.east) --node [above] {No} +(1,0) |- ( $(c)!0.5!(d)$ ); because I wanted it to actually touch the line. –  blitzvergnugen Sep 4 '12 at 19:57
A couple follow up questions if you don't mind. The \y1 does that reference the y-coordinate of a.east? And can you reference \p1 outside of that line? –  blitzvergnugen Sep 4 '12 at 19:59
@blitzvergnugen \p1 "holds" the coordinates of (c)!0.5!(d); the x-coordinate can be retrieved using \x1, and the y-ccordinate, using \y1. The definition is local; but you could use macros to store the values globally. –  Gonzalo Medina Sep 4 '12 at 20:02
@blitzvergnugen to extract coordinates you could also use the \pgfextractx, \pgfextracty macros (see Section 70.6 of the pgfmanual). –  Gonzalo Medina Sep 4 '12 at 20:22
Awesome. Thanks. –  blitzvergnugen Sep 4 '12 at 20:28