Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
3  
Can you complete your code to a minimal working example (MWE) and maybe add a sketch (might be done in Paint or by hand) of what you want to achieve? –  Qrrbrbirlbel Oct 22 '13 at 15:27
1  
thank you, I'm modifying my question now. –  mbigras Oct 22 '13 at 15:52
    
@mbigras Looks like you already have a solution. Sure, TikZ offers a few other ways to do this; do you want to know these or what would be your question? –  Qrrbrbirlbel Oct 22 '13 at 16:39

3 Answers 3

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

share|improve this answer

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}
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.