# Drawing a figure of three wires, coupled at specific points

I am trying to draw a three wire network(shown by three different colors), as shown below.
This is my MWE, but I am messing up some where, as my wires are coming on top of each other unlike what I want.

\documentclass[border=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand\wireheight{2} % height of one segment
\newcommand\wirewidth{1}  % width of a segment
\newcommand\wiredist{0.5} % distance between wires
\pgfmathsetmacro\pairdist{2*(\wirewidth+\wiredist)} % distance between pairs of wires

% \wire[options]{name}{start}{height}{width}
\newcommand\wire[5][]%
{\draw[#1]
(#3)            coordinate (#2-0)
-- ++(0,#4)     coordinate (#2-1)
-- ++(#5,0)     coordinate (#2-2)
-- ++(0,#4)     coordinate (#2-3)
-- ++(-#5,0)    coordinate (#2-4)
-- ++(0,#4)     coordinate (#2-5)
-- ++(#5,0)     coordinate (#2-6)
-- ++(0,0.5*#4) coordinate (#2-7);
}

\begin{document}
\begin{tikzpicture}[rounded corners,>=stealth, shorten >=1pt, shorten <=1pt]
\foreach \i in {0,...,2}
{
\wire[thick,blue]{G-\i}{{(\i)*\pairdist-\wiredist},0}{\wireheight}{-\wirewidth}
\wire[thick,blue]{B-\i}{\i*\pairdist,0}{\wireheight}{\wirewidth}
\wire[thick,blue]{B-\i}{\i*\pairdist,1}{\wireheight}{\wirewidth}
}
\draw[<->] ($(G-1-2)!0.5!(G-1-3)$) -- +(-0.5,0) node[midway,above]{$\theta_{2}$};
\draw[<->] ($(G-1-2)!-0.5!(G-2-3)$) -- +(-0.5,0) node[midway, above]{$\theta_{1}$};
\end{tikzpicture}
\end{document}

• The third argument, #3, to \wire is supposed to give a tikz coordinate when used as (#3) but you are giving it things like {(\i)*\pairdist-\wiredist},0. In this case, you probably want \i*\pairdist-\wiredist,0. Once this is fixed you will of course need to adjust the values of #4 and #5 to get different shapes for your wires. – Andrew Apr 30 '18 at 11:14

Hopefully this is what you had in mind

\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand\wireheight{2} % height of one segment
\newcommand\wirewidth{1}  % width of a segment
\newcommand\wiredist{0.5} % distance between wires
\newcommand\fwidth{0.7} % for the black wire
\pgfmathsetmacro\blockwidth{2 * \wirewidth + \fwidth * \wirewidth + 3 * \wiredist} % block size

\newcommand\mup[1]{-- ++ (90 : #1 * \wireheight)}
\newcommand\mright[1]{-- ++ (0 : #1 * \wirewidth)}
\newcommand\mleft[1]{-- ++ (180 : #1 * \wirewidth)}
% \wire[options]{name}{start}{width}
\newcommand\gwire[4][]{
\draw[#1] (#3, 0) \mup{1} \mright{#4} \mup{1} \mleft{#4} \mup{2} \mright{#4} \mup{1} \mleft{#4} \mup{1} \mright{#4} \mup{1} coordinate (#2-1);
}
\newcommand\kwire[4][]{
\draw[#1] (#3, 0) ++ (#4, 0) \mup{1} \mleft{#4} \mup{1.3} \mright{#4} \mup{1.7} \mleft{#4} \mup{1.2} \mright{#4} \mup{1.8} coordinate (#2-1);
}
\newcommand\bwire[4][]{
\draw[#1] (#3, 0) \mup{2} \mright{#4} \mup{1} \mleft{#4} \mup{2} \mright{#4} \mup{1} \mleft{#4} \mup{1} coordinate (#2-1);
}

\begin{document}
\begin{tikzpicture}[rounded corners,>=stealth, shorten >=1pt, shorten <=1pt]

\foreach \i in {0,...,2}
{
\gwire[thick,green]{G-\i}{\i * \blockwidth}{1}
\kwire[thick,black]{K-\i}{\i * \blockwidth + \wirewidth + \wiredist}{\fwidth}
\bwire[thick,blue]{B-\i}{\i * \blockwidth + \wirewidth + \fwidth * \wirewidth + 2 * \wiredist}{1}
}

\draw[<->] (K-0-1) -- (B-0-1) node[above, midway]{$\theta_1$};
\end{tikzpicture}
\end{document}

• Precisely, this is what I would like to get. Extremely thankful to you and for your time. Is there a way to write those $\theta$(s)? – Shamina Apr 30 '18 at 12:48
• @Shamina Sure, you just need to add coordinates as you did in your example code – caverac Apr 30 '18 at 13:05
• To move the theta_2 along y-axis, do I need to change the (K-0-1) -- (B-0-1) the 1 to the y-coordinate? Can you remind me these points, thanks? Seem to be forgetting. So that I will be able to do it by myself, without disturbing you further – Shamina Apr 30 '18 at 13:19
• @Shamina No, 1 in (K-0-1) is just a label that I added at the last point of the path. If you want labels for all corners you need to add them manually with coordinate(#2-<label>), a simpler solution is just \draw[<->] ($(K-0-1)+(0,-1)$) -- ($(B-0-1)+(0,-1)$) node[above, midway]{$\theta_1$}; – caverac Apr 30 '18 at 13:23