我正在尝试绘制一个更复杂的图,但没有成功。我希望将一个刚度和阻尼器(KR 和 CR)与仅带有弹簧(K4)的开口端连接起来。此外,我正在使用一个最初回答的问题,我正在对其进行修改。他们有办法将完成的图表旋转 90 度吗?垂直站立而不是水平站立(就像现在这样)。谢谢
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings}
\begin{document}
\begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
\tikzset{
spring/.style = {thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment
length=6}},
damper/.style ={thick,decoration={markings,
mark connection node=dmp,
mark=at position 0.5 with
{
\node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum
width=15pt,minimum height=3pt,draw=none] {};
\draw [thick] ($(dmp.north east)+(1pt,0)$) -- (dmp.south east) -- (dmp.south
west) -- ($(dmp.north west)+(1pt,0)$);
\draw [thick] ($(dmp.north)+(0,-5pt)$) -- ($(dmp.north)+(0,5pt)$);
}
}, decorate},
ground/.style ={fill,pattern=north east lines,draw=none,minimum width=0.75cm,minimum height=0.3cm}
}
\begin{scope}[rotate=-90,transform shape] %%% rotate here, both options needed.
\node (wall) [ground, minimum width=3cm,anchor=center] at (0,0) {};
\node (walle) [ground, minimum width=3cm,anchor=center] at (0,6) {};
\draw (wall.north east) -- (wall.north west);
\draw (walle.south west) -- (walle.south east);
%% now a parallel spring
\draw [line width=0.8pt] ($(wall.north west)!0.2!(wall.north east)$) -- ++(0,2cm)coordinate (z);
\draw [spring] (z) -- ++(0,2cm)coordinate (t);
\draw [line width=0.8pt] (t) -- ($(walle.south west)!0.2!(walle.south east)$);
\end{scope}
\begin{scope}[rotate=-90,transform shape] %%% rotate here, both options needed.
\draw [line width=0.8pt] ($(wall.north west)!0.8!(wall.north east)$) -- ++(0,1cm)coordinate (z);
\draw [spring] (z) -- ++(0,2cm)coordinate (t);
%\draw [damper] (t) -- ++(0,2cm)coordinate (u);
\draw (-0.5,0) -- (0.5,0);
\draw [spring] (-0.5,-2) -- (-0.5,0) node[draw=none,midway,left=0.3cm] {${k}{_R}$};
\draw [damper,label=D1,] (0.5,-2) -- (0.5,0)node[draw=none,midway,right=0.4cm] {${C}{_R}$};
\draw (-0.5,-2) -- (0.5,-2);
%\draw [line width=0.8pt] (u) -- ($(walle.south west)!0.8!(walle.south east)$);
\end{scope}
\end{tikzpicture}
\end{document}
答案1
一种选择是使用从(t)
坐标(带有弹簧的左线下端)定义的辅助坐标
\coordinate (upperright) at ( $ (t)+(0.5,0) $ );
\coordinate (lowerleft) at ( $ (t)+(-0.5,-2) $ );
然后使用这些坐标绘制“矩形”组件
\draw (lowerleft) -- (lowerleft-|upperright);
\draw (upperright) -- (lowerleft|-upperright);
\draw [damper,label=D1,]
(lowerleft|-upperright) -- (lowerleft)
node[draw=none,midway,left=0.3cm] {${C}{_R}$};
\draw [spring]
(upperright) -- (lowerleft-|upperright)
node[draw=none,midway,right=0.1cm] {${k}{_R}$};
ground
现在可以使用以下公式获得连接矩形组件和下部节点的垂直线段
\draw [line width=0.8pt]
($(wall.north west)!0.8!(wall.north east)$) -- (t|-lowerleft);
抑制范围内的旋转并改变 y 坐标中的某些符号会给您所需的方向(如果我理解正确的话)。
完整代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings}
\begin{document}
\begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
\tikzset{
spring/.style = {thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment
length=6}},
damper/.style ={thick,decoration={markings,
mark connection node=dmp,
mark=at position 0.5 with
{
\node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum
width=15pt,minimum height=3pt,draw=none] {};
\draw [thick] ($(dmp.north east)+(1pt,0)$) -- (dmp.south east) -- (dmp.south
west) -- ($(dmp.north west)+(1pt,0)$);
\draw [thick] ($(dmp.north)+(0,-5pt)$) -- ($(dmp.north)+(0,5pt)$);
}
}, decorate},
ground/.style ={fill,pattern=north east lines,draw=none,minimum width=0.75cm,minimum height=0.3cm}
}
\node (wall) [ground, minimum width=3cm,anchor=center] at (0,0) {};
\node (walle) [ground, minimum width=3cm,anchor=center] at (0,6) {};
\draw (wall.north east) -- (wall.north west);
\draw (walle.south west) -- (walle.south east);
%% now a parallel spring
\draw [line width=0.8pt]
($(wall.north west)!0.2!(wall.north east)$) -- ++(0,2cm)coordinate (z);
\draw [spring]
(z) -- ++(0,2cm)coordinate (u);
\draw [line width=0.8pt]
(u) -- ($(walle.south west)!0.2!(walle.south east)$);
\draw [line width=0.8pt]
($(walle.south west)!0.8!(walle.south east)$) -- ++(0,-1cm)coordinate (w);
\draw [spring] (w) -- ++(0,-2cm)coordinate (t);
\coordinate (upperright) at ( $ (t)+(0.5,0) $ );
\coordinate (lowerleft) at ( $ (t)+(-0.5,-2) $ );
\draw (lowerleft) -- (lowerleft-|upperright);
\draw (upperright) -- (lowerleft|-upperright);
\draw [damper,label=D1,]
(lowerleft|-upperright) -- (lowerleft)
node[draw=none,midway,left=0.3cm] {${C}{_R}$};
\draw [spring]
(upperright) -- (lowerleft-|upperright)
node[draw=none,midway,right=0.1cm] {${k}{_R}$};
\draw [line width=0.8pt]
($(wall.north west)!0.8!(wall.north east)$) -- (t|-lowerleft);
\end{tikzpicture}
\end{document}