我习惯使用 tikz 和 circuitikz 以以下方式绘制基本机械部件(弹簧、减震器):
\coordinate (A) at (0,0);
\coordinate (B) at (3,0);
[...]
\draw (A) to[spring] (B);
\draw (C) to[damper] (D);
现在我处于一个配置中,我想在弧,不是一行:
\draw (0,0) + (30:3cm) arc (30:80:3cm);
我尝试过使用to[spring]
位于弧线命令之前和之后的定位(见图),但没有成功,并且:
\draw[damper] (0,0) + (30:3cm) arc (30:80:3cm);
我见过这里,这里和这里使用线圈是可能的decorations
,但我希望保持相同的弹簧表示,并且阻尼器的解决方案似乎相当复杂,有没有更简单的方法来实现?
编辑:工作示例
\usepackage{tikz}
\usepackage{circuitikz}
%
\begin{figure} [h]
\begin{tikzpicture}
\coordinate (elbow) at (0,0);
\coordinate (shoulder) at ($(elbow) + (0, 3.25)$);
%
\draw[rounded corners=1ex, rotate around={-60:(elbow)}] (0.175, 0) rectangle (-0.175, 3.25);
\draw[rounded corners=0.5ex] ($(elbow) + (0.175, 0)$) rectangle ($(shoulder) + (-0.175, 0)$) node (wrist){};
\node[circle, draw, minimum size=1.25cm, fill=white] (joint) at (elbow) {};
\node[circle, draw, minimum size=0.15cm, inner sep=0, fill=white] (jointBis) at (elbow) {};
%
\draw[white, line width=1.5pt] (0,0) + (15:0.625cm) arc (15:45:0.625cm);
%
\draw (0,0) + (33:3cm) arc (33:87:3cm); %to[spring]
\draw[damper] (0,0) + (35:2cm) arc (35:85:2cm);
%
\draw[gray, dashed] (0.625,0) -- (3,0);
\draw[-{Latex[length=2mm]}] (0,0) + (0:2cm) arc (0:25:2cm) node[midway, right]{$\theta$};
\end{tikzpicture}
\end{figure}
答案1
沿圆弧定位节点并不是那么困难 --- 问题是circuitikz
元素只能使用语句自动沿直线定位to
。
因此,要将元素定位在圆弧上,我们必须依靠使用“裸”节点并对其进行定位。例如
\path (0,0) +(30:3cm) arc (30:80:3cm)
node[draw, springshape, pos=0.5, sloped](S){};
会给:
现在,最大的问题是连接元素并移除下面的线。我在这里用了一些三角函数(当然它可以在某些宏中自动实现……);例如 --- 我用红色标出了指导我构造的帮助线:
\begin{tikzpicture}[]
% these are to show the construction
\draw[red,thin] (0,0) + (30:3cm) coordinate(B)
arc (30:80:3cm) coordinate(E);
\node[red] at (B){B}; \node[red] at (E){E};
\path (B) arc (30:80:3cm) node[draw, springshape, pos=0.5, sloped](S){};
% from B the circle starts at 120 degree, let's se e the landing angle and use a spline
\draw let \p1=(S.right), \n1={-90+acos(\x1/3cm)}
in (B) to[out=120,in=\n1] (S.right);
% from E it starts at -10, let's caluclate the landing angle
\draw let \p1=(S.left), \n1={90+acos(\x1/3cm)}
in (E) to[out=-10,in=\n1] (S.left);
\end{tikzpicture}
因此这些圆弧实际上并不是圆弧,但最终结果(去除红色部分)对我来说似乎是可以接受的:
\path (0,0) +(30:3cm) coordinate(B)
arc (30:80:3cm) coordinate(E)
node[draw, springshape, pos=0.5, sloped](S){};
% from B the circle starts at 120 degree, let's se e the landing angle and use a spline
\draw let \p1=(S.right), \n1={-90+acos(\x1/3cm)}
in (B) to[out=120,in=\n1] (S.right);
% from E it starts at -10, let's caluclate the landing angle
\draw let \p1=(S.left), \n1={90+acos(\x1/3cm)}
in (E) to[out=-10,in=\n1] (S.left);
使用阻尼器时,使用在手册中找到的元素的节点名称:
获得: