Home > tikz pgf > Path to midpoint of other path

Path to midpoint of other path

September 4Hits:1
Advertisement

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} 

Path to midpoint of other path

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.

Answers

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}

Path to midpoint of other path

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}

Path to midpoint of other path

Tags:tikz pgf

Related Articles

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 3.372 s.