Tikz 未对齐圆圈 - 圆弧填充

Tikz 未对齐圆圈 - 圆弧填充

我在绘制一个圆圈然后使用 tikz 填充它的一部分时遇到了问题。

我的代码(希望我usepackage已经包含 MWE 所需的所有代码,因为标题太大而且管理不善):

\documentclass{book}

\usepackage[left=3.0cm, right=2.5cm, top=2.5cm,bottom=2.0cm,includeheadfoot]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,decorations.markings,arrows,positioning,intersections,patterns,scopes,datavisualization}
\usepackage{tikzscale}

\begin{document}

\begin{figure}
\centering
\includegraphics[width=\textwidth]{fig.tikz}
\end{figure}
\end{document}

内容fig.tikz

\begin{tikzpicture}[x=0.1mm,y=2.0000mm]
   \draw ($(   0.000,   8.138)+(0,3.00)$) coordinate (pnt9) circle (2mm);
   \draw (   0.000,   8.138) -- (pnt9);
   \fill[fill=black] (pnt9) -- ++(0,2mm) arc (90:0.0000:2mm) -- cycle;
   \fill[fill=black] (pnt9) -- ++(0,-2mm) arc (270:173.6690:2mm) -- cycle;
\end{tikzpicture}

我得到的结果如下:

我从中得到的结论是,圆心并不位于所有其他元素所在的位置。大多数代码是由另一个程序生成的。

我尝试搜索类似的问题,但无济于事。

答案1

原图是分钟。Ti默认情况下,Z 值不是很准确。因此,当你将某个微小物体缩放到其自然大小的很多很多倍时,误差就会逐渐显现,舍入误差不可避免地会降低输出质量。

解决方案是首先不要让原始图片变得如此小。除了图片的第一行之外,x=和选项没有做太多事情,因为其他地方都指定了具体尺寸,所以我只是消除了这一点,并在第一行将乘以。(最初,应该是。然后我删除了所有的,这样我们就得到了更合理的自然尺寸。然后它就可以很好地缩放了。y=326mmmm

\begin{filecontents}{\jobname-fig.tikz}
\begin{tikzpicture}
   \draw (0,6) coordinate (pnt9) circle (2);
   \draw (0,0) -- (pnt9);
   \fill[fill=black] (pnt9) -- ++(0,2) arc (90:0:2) -- cycle;
   \fill[fill=black] (pnt9) -- ++(0,-2) arc (270:173.669:2) -- cycle;
\end{tikzpicture}

\end{filecontents}
\documentclass{book}
\usepackage[left=3.0cm, right=2.5cm, top=2.5cm,bottom=2.0cm,includeheadfoot]{geometry}
\usepackage{tikz}
\usepackage{tikzscale}

\begin{document}
\begin{figure}
  \centering
  \includegraphics[width=\textwidth]{\jobname-fig}
\end{figure}
\end{document}

大一点

如果您不缩放原始图像,而只是将其包含在\input{}或中,它看起来也不错\includegraphics{}。当然,它有点太小了,但如果您放大 1,600% 左右,它看起来就很好了 - 仍然有点小,但对于所有这些来说已经很完美了。

答案2

经过我自己尝试之后,我发现将坐标定义与圆的绘制分开也可以解决问题。

\begin{tikzpicture}[x=0.1mm,y=2.0000mm]
  \coordinate (pnt9) at ($(   0.000,   8.138)+(0,3.00)$);
  \draw (pnt9) circle (2mm);
  \draw (   0.000,   8.138) -- (pnt9);
  \fill[fill=black] (pnt9) -- ++(0,2mm) arc (90:0.0000:2mm) -- cycle;
  \fill[fill=black] (pnt9) -- ++(0,-2mm) arc (270:173.6690:2mm) -- cycle;
\end{tikzpicture}

相关内容