# Help With TikZ: Recreating Diagrams from e/m Ratio Experiment—Helmholtz Coils and Circuitry

I have two images I need to recreate in TikZ. The first is that of Helmholtz coils and their spacing in the experiment:

And the second being the wiring for the coils:

My (very) Minimal working example for the first picture is as follows:

\begin{figure}
\centering
\begin{tikzpicture}
\draw(1, 1) circle (170 pt);

\draw(7, 7) -- (9, 7);

\draw (8, 1) node {\Huge $d$};

\path[->,>=angle 90, thick](8, 2) edge (8,6.5);

\path[->,>=angle 90, thick](8, 0) edge (8, -4.5);

\draw(7, -5) -- (9, -5);

\draw[very thick] (-4.5, 7) rectangle (-2.5, -5);

\draw[very thick] (4.5, 7) rectangle (6.5, -5);

\draw[loosely dashed] (-3.5, 9) -- (-3.5, -7);

\draw[loosely dashed] (5.5, 9) -- (5.5, -7);

\draw (1, 1) node {\Huge $\frac{d}{2}$};

\path[->,>=angle 90, thick](0, 1) edge (-3.5, 1);

\path[->,>=angle 90, thick](2, 1) edge (5.5, 1);

\path[->,>=angle 90, very thick] (0, 3) edge (2, 3);

\end{tikzpicture}
\caption{Helmholtz Coil Geometry}
\label{Helmholtz}
\end{figure}


And for the Second Image, which is even more minimal, I have

    \begin{figure}
\centering
\begin{tikzpicture}
\draw[thick] (0, 5) rectangle (7, 0);

\draw[thick] (-6, 7) rectangle (-2, -0.5);

\draw[thick]  (1, 4.2) circle (5 pt);

\draw[thick]  (3.5, 3.9) circle (5 pt);

\draw[thick]  (6, 4.2) circle (5 pt);

\draw[thick]  (1, 0.8) circle (5 pt);

\draw[thick]  (3.5, 1.1) circle (5 pt);

\draw[thick]  (6, 0.8) circle (5 pt);

\end{tikzpicture}
\caption{Wiring Diagram for Helmholtz Coils}
\label{Circuit}
\end{figure}


-
I have never understood why people who have a perfectly good graphic that they can put on this website, can't just copy and paste that into their own document and give an appropriate citation... That's got to be a better use of time! –  Andy Clifton May 18 '13 at 22:19
@LostBrit I completely understand that, and I know it's a bit of a waste of time, but as a new TikZ user, this could be a learning experience for me. Also, there is a bit more freedom of line placement and coloring, which I could play with at my leisure! –  Reuben Stern May 18 '13 at 22:21
@LostBrit: You have half a valid point there. Often you have a graphic in medium resolution that look fine in the PDF, but not so much once you print it. This graphic is slightly blurry, this will probably look a lot worce when printing. On the other hand, just recreating is boring, I'll admit that. So one could try to improve it on the way ;-) –  Tom Bombadil May 18 '13 at 23:24

Here's a pseudo 3D variation. Note however that nodes with the 3d library behave strangely (only single nodes work, still need three coordinates...)

## Code

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3d,arrows}

% fix the implementation of "canvas is xy plane at z"
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane
}
\makeatother

% define styles for the three coordinate planes
\tikzset{xyp/.style={canvas is xy plane at z=#1}}
\tikzset{xzp/.style={canvas is xz plane at y=#1}}
\tikzset{yzp/.style={canvas is yz plane at x=#1}}

\begin{document}

\begin{tikzpicture}[x={(-30:1cm)},y={(190:1cm)},z={(90:1cm)}]% set unit vectors

% "back" coil and optical axis
\filldraw[yzp=-1.1,gray!80,draw=black,even odd rule](0,0) circle (1.8) (0,0) circle (2.2);
\draw[densely dashdotted,yzp=-1](0,-2.9) -- (0,-2.2)  (0,-1.8) -- (0,1.8)  (0,2.2) -- (0,2.9);
\filldraw[yzp=-0.9,gray,draw=black,even odd rule](0,0) circle (1.8) (0,0) circle (2.2);

% experimental zone and text
\filldraw[xzp=0,red,opacity=0.5,draw=red!50!black](0,0) circle (2);
\draw[xzp=0,shorten <=0.5mm,shorten >=-1mm] (0,2) -- (0.4,3.5);
\node[xzp=0,above,font=\footnotesize] at (0.4,0,3.5) {experimental zone};

% magnetic field arrow and text; note that "latex" is a special arrow
\draw[xzp=0,-latex] (-0.4,-1.4) -- (0.4,-1.4);
\node[below,xzp=0] at (0,0,-1.4) {$\mathbf{B}$};
\node[above,xzp=0,font=\footnotesize] at (0,0,-1.4) {magnetic field};

% half diameter and text
\draw[xzp=0,latex-latex] (-1,1) -- (1,1);
\node[xzp=0,below] at (0.75,0,1) {$\frac{d}{2}$};

% "front" coil and optical axis
\filldraw[yzp=0.9,gray!80,draw=black,even odd rule](0,0) circle (1.8) (0,0) circle (2.2);
\draw[densely dashdotted,yzp=1](0,-2.9) -- (0,-2.2)  (0,-1.8) -- (0,1.8)  (0,2.2) -- (0,2.9);
\filldraw[yzp=1.1,gray,draw=black,even odd rule](0,0) circle (1.8) (0,0) circle (2.2);

% diameter and text
\draw[xzp=0] (1.1,2) -- (2,2) (1.1,-2) -- (2,-2);
\draw[xzp=0,latex-latex] (1.8,2) -- (1.8,-2);
\node[xzp=0,right] at (1.8,0,1.6) {$d$};
\end{tikzpicture}

\end{document}


## Output

Edit 1: For the second picture you can use nodes (and coordinates for zero width nodes) which will make the connections easier. For the coils you can hace a look at the circuits library.

## Code

\begin{tikzpicture}
\draw[thick] (0, 5) rectangle (7, 0);

\draw[thick] (-6, 7) rectangle (-2, -0.5);

\draw[thick] (-5.5, 0) rectangle (-3, 1.5);
\node[right] at (-3,0.75) {A};
\foreach \x in {10,20,...,170} \draw (-4.25,0) ++ (\x:1) -- ++(\x:0.2);
\draw[very thick,-latex] (-4.25,0) -- ++ (85:0.95);

\node[circle,draw,inner sep=1.5mm] (tl) at (1, 4.2) {};
\node[circle,draw,inner sep=1.5mm] (tm) at (3.5, 3.9) {};
\node[circle,draw,inner sep=1.5mm] (tr) at (6, 4.2) {};
\node[circle,draw,inner sep=1.5mm] (bl) at (1, 0.8) {};
\node[circle,draw,inner sep=1.5mm] (bm) at (3.5, 1.1) {};
\node[circle,draw,inner sep=1.5mm] (br) at (6, 0.8) {};

\node[inner sep=0.5mm,circle,draw,label=180:+] (plus) at (-2.5,5) {};
\draw (-2.5,5) circle (0.15);
\draw[-latex] (plus) -| ++ (1,3) -| node[pos=0.25,circle,fill=white,draw] {A} (tm);

\draw[latex-latex] (tl) -- (1,3.5) -- (6,1.5) -- (br);
\draw[latex-latex] (tr) -- (6,3.5) -- (1,1.5) -- (bl);
\end{tikzpicture}


-
Thanks! Say I want it rotated a bit to the right, how would I do that? Change the unit vectors? –  Reuben Stern May 18 '13 at 23:45
Exactly! This will however not work for all angles, as the coils are not solid (just two rings). –  Tom Bombadil May 18 '13 at 23:46