绘制分段圆

绘制分段圆

我正在尝试绘制另一个更大的圆圈,其中心也为 (0,0)。用文字表达就是“沿着顶部水平臂走到它的中点,然后画一个圆圈一直走到底部水平臂的中点”。我怎样才能将这些文字转换成可用的代码?

% 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);

这就是我处理此事的方式。

% 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);

平均能量损失

感谢大家的以下回答,我计划解决这些问题。

答案1

这只是 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}

在此处输入图片描述

答案2

您可以使用该包tkz-euclide进行以下几何绘图:

\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}

答案3

invclip保罗·加博里特的钥匙回答,关键是saveuse path,您可以相对轻松地绘制此图,而无需进行任何计算。

代码

\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}

输出

在此处输入图片描述

相关内容