5

I'm trying to draw another larger circle that is also centered at (0,0). In words I'd like to "walk out along the top horizontal arm to its halfway point, then draw a circle all the way around to the halfway point on the bottom horizontal arm". How can I turn these words into working code?

% vacuum
\draw (15:8) arc (15:345:8);
\draw (15:8) -- ++(5,0);
\path [name path=vacuum bottom horizontal] (345:8) -- ++(6,0);
\path [name path=vacuum vertical] (15:8) -- ++(5,0) -- ++(0,-15);
\draw[name intersections={of=vacuum bottom horizontal and vacuum vertical, by=bot}]
(15:8) ++(5,0) -- (bot);
\draw (345:8) -- ++(5,0);

This is the way that I've gone about it.

% helmholtz coil
\coordinate (A) at (15:8);
\coordinate (B) at (345:8);

\draw let \p1 = ($(A) +(2.5,0)$),
\p2 = ($(B) +(2.5,0)$),
\n1 = {atan(\y1/\x1)},
\n2 = {atan(\y2/\x2)+360},
\n3 = {veclen(\x1,\y1)}
in
(\n1:\n3) arc (\n1:\n2:\n3);

MWE

Thank you all for the answers below, I plan to work through them.

mbigras
  • 395
  • 1
  • 2
  • 8

3 Answers3

6

Just another solution with PSTricks.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}(-4,-4)(5,4)
    \pnodes(0,0){O}(3;15){A}([nodesep=1]A){B}(3;-15){C}([nodesep=1]C){D}
    \pstArcOAB{O}{A}{C}
    \pstArcOAB{O}{B}{D}
    \ncbar[arm=2]{A}{C}
\end{pspicture}
\end{document}

enter image description here

5

You can use the package tkz-euclide for these geometric drawings:

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=0.2]
% vacuum
\draw (15:8) arc (15:345:8);
\draw (15:8) --coordinate[pos=0.5](MPT) ++(5,0);
\path [name path=vacuum bottom horizontal] (345:8) -- ++(6,0);
\path [name path=vacuum vertical] (15:8) -- ++(5,0) -- ++(0,-15);
\draw[name intersections={of=vacuum bottom horizontal and vacuum vertical, by=bot}]
(15:8) ++(5,0) -- (bot);
\draw (345:8) --coordinate[pos=0.5](MPB) ++(5,0);
% helmholtz coil
\coordinate (A) at (15:8);
\coordinate (B) at (345:8);
\coordinate(O) at (0,0);

\tkzDrawArc[color=black](O,MPT)(MPB)
\end{tikzpicture}

\end{document}
Toscho
  • 4,713
5

With the invclip key from Paul Gaborit’s answer, and the saveuse path key, you can draw this diagram relatively easy without any calculations.

Code

\documentclass[tikz]{standalone}
\tikzset{
  declare function={innerR=.8; outerR=innerR+.25; angle=15;},
  invclip/.style={
    clip,
    insert path={{[reset cm] (-16000pt,-16000pt) rectangle (16000pt,16000pt)}}},
  saveuse path/.code 2 args={
    \pgfkeysalso{#1/.estyle={insert path={#2}}}%
    \global\expandafter\let\csname pgfk@\pgfkeyscurrentpath/.@cmd\expandafter\endcsname % not optimal as it is now global through out the document
                           \csname pgfk@\pgfkeyscurrentpath/.@cmd\endcsname
    \pgfkeysalso{#1}}}
\def\invclip#1;{\pgfinterruptboundingbox\path[invclip]#1;\endpgfinterruptboundingbox}
\begin{document}
\begin{tikzpicture}
\draw [saveuse path={inner part}{(angle:innerR)
  arc[radius=innerR, start angle=angle, end angle=360-angle]
  -- ++ (right:2*outerR-2*innerR) |- (angle:innerR) -- cycle}] ;
\invclip [inner part];
\draw circle[radius=outerR];
\end{tikzpicture}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821