\documentclass[convert = false, tikz]{standalone}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0, 0);
\coordinate (M) at (4, 0);
\def\angle{130}
\draw (O) -- (M);
\draw (M) -- ++(\angle:2cm) coordinate (SOI);
\begin{pgfinterruptboundingbox}
\path[name path global = circ] (O) circle[radius = 1.5cm];
\path[name path global = xline] (O) -- +(-10, 0);
\path[name path global = yline] (O) -- +(0, 2);
\path[name path global = toE] (SOI) -- ++(-170:8cm);
\path[name intersections = {of = yline and toE, by = E}];
\path[name intersections = {of = xline and toE, by = I}];
\path[name intersections = {of = circ and toE, by = P1}];
\end{pgfinterruptboundingbox}
\draw (SOI) -- (E);
\draw[-latex] let
\p0 = (I),
\p1 = (M),
\p2 = (P1),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {1.5cm}
in (I) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\draw[-latex] let
\p0 = (O),
\p1 = (M),
\p2 = (P1),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {1.5cm}
in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\draw[-latex] let
\p0 = (I),
\p1 = (M),
\p2 = (SOI),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {1.5cm}
in (I) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\draw[-latex] let
\p0 = (O),
\p1 = (M),
\p2 = (SOI),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {1.5cm}
in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\end{tikzpicture}
\end{document}
- 使用
(P1)
如果我们考虑上面的代码,足够长的弧线会弯曲太多,而具有适当弯曲量的弧线又太短。在这种情况下,如何才能获得具有正确长度的适当弯曲量?
- 使用
(SOI)
两条曲线都太短,但似乎都没有超出弧度。
我可以在这里做什么?
@Jake,您的代码切换y
并x
旋转了我的矢量,使其看起来是水平的而不是垂直的。
\draw[-latex] let
\p0 = (O),
\p1 = (M),
\p2 = (SOI),
\n1 = {atan2(\y1 - \y0, \x1 - \x0)},
\n2 = {atan2(\y2 - \y0, \x2 - \x0)},
\n3 = {veclen(\x2 - \x0, \y2 - \y1)},
\n4 = {(\n1 + \n2) / 2}
in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
您发布的上述代码产生:
回到然后x
产生y
:
问题在于(I)
坐标。它实际上从未存在,但LaTeX
没有返回任何错误。路径toE
从未与相交xline
。因此,当我从绘制时(I)
,构成交叉点原点的圆路径位于上方y = 0
。因此,导致(I)
圆弧很短。要纠正此问题,请设置
\path[name path global = toE] (SOI) -- ++(-170:9cm);
将射线的半径从9cm
改为8cm
。
答案1
问题在于(I)
坐标。它实际上从未存在,但LaTeX
没有返回任何错误。路径toE
从未与相交xline
。因此,当我从绘制时(I)
,构成交叉点原点的圆路径位于上方y = 0
。因此,导致(I)
圆弧很短。要纠正此问题,请设置
\path[name path global = toE] (SOI) -- ++(-170:9cm);
将射线的半径从9cm
改为8cm
。
在当前设置下,从未存在交叉点。
不幸的是,LaTeX
永远不会吐出错误,让线
\path[name intersections = {of = xline and toE, by = I}];
(I)
在 的末尾创建点toE
。由于我构建了路径,所以我实际上无法看到这一点,直到我决定仔细观察,并且没有错误消息说没有交点或类似的东西,我被引导相信一切正常。
通过新的变化,我们得到
通过设置
\path[name path global = circ] (I) circle[radius = 7cm];
并使用Jake的删除方法veclen
并将其放入,pgfinterruptboundingbox
否则您将会有不必要的空白。
\draw[-latex] let
\p0 = (I),
\p1 = (M),
\p2 = (P1),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {veclen(\x2 - \x0, \y2 - \y1)},
\n4 = {(\n1 + \n2) / 2}
in (I) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
node[font = \tiny, fill = white, inner sep = 0] at ([shift = (I)] \n4:\n3)
{\(\phi_1\)};