我沿着线剪了一个圆atan(2/3)
。我想在剪圆的地方放一个箭头。我以为这很简单,只要(atan(2/3) + 180)/360
得到它在路径上的百分比位置就行了。不幸的是,事实并非如此。我最终32.5
因为反复试验而减去了度数。不过我想做一个更精确的位置。
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\angle}{atan(2/3)};
\pgfmathsetmacro{\ppi}{\angle + 180};
\pgfmathsetmacro{\percent}{(\ppi - 32.5)/360};
\begin{scope}[rotate = \angle, decoration = {
markings,
mark = at position \percent with {\arrow{stealth}}
}]
\clip (0, .4) rectangle (-.45, 0);
\draw[postaction = decorate] (cylinder) circle[radius = .395cm];
\end{scope}
\end{tikzpicture}
\end{document}
答案1
让我们分析一下。没有\clip
旋转,没有绘制矩形,这是你的圆:
这表明该\percent
值应该是50
。使用
\pgfmathsetmacro{\ppi}{\angle + 180};
\pgfmathsetmacro{\percent}{(\ppi)/360};
你给的肯定不止50%
这些。确切地说,你给的atan(2/3)
更多\ppi
。如果我们让\ppi
= 180,那么\percent
将是50
。
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\angle}{atan(2/3)};
\pgfmathsetmacro{\ppi}{180};
\pgfmathsetmacro{\percent}{(\ppi)/360};
\begin{scope}[rotate = 0, decoration = {% % change rotate to \angle
markings,
mark = at position \percent with {\arrow{stealth}}
}]
%\clip (0, .4) rectangle (-.45, 0);
\draw (0, .4) rectangle (-.45, 0);
\draw[postaction = decorate] (0,0) circle[radius = .395cm];
\end{scope}
\end{tikzpicture}
\end{document}
现在您可以旋转并剪辑以获得:
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\angle}{atan(2/3)};
\pgfmathsetmacro{\ppi}{180};
\pgfmathsetmacro{\percent}{(\ppi)/360};
\begin{scope}[rotate = \angle, decoration = {
markings,
mark = at position \percent with {\arrow{stealth}}
}]
\clip (0, .4) rectangle (-.45, 0);
%\draw (0, .4) rectangle (-.45, 0);
\draw[postaction = decorate] (0,0) circle[radius = .395cm];
\end{scope}
\end{tikzpicture}
\end{document}