对于以下机电系统示意图,我想要:
1-尽可能减少和优化以下代码:
N_1
通过指定其长度和旋转从其中心绘制一条线(例如下方和上方的线N_2
)找到一种更紧凑的方式来定位和绘制图案填充的矩形,而不是定义坐标
找到一种更优化的方法,将扭曲的箭头放置在垂直线和电机和气缸之间的中间
2- 将电流箭头i_a
置于电阻和电感之间的中心,
(M1.east)
3-了解与旁边的水平线之间的间隙存在的原因。
mm
4-知道为什么我需要写下该单位xshift
并yshift
使其按预期工作。
5-将E_a
其正负符号向右移动,与电路端子水平对齐。即符号和端子都应E_a
水平对齐。
非常感谢进一步的建议和代码减少。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{arrows,shapes,calc, positioning, patterns, decorations, decorations.markings}
\newcommand{\mymotor}[2] % #1 = name , #2 = rotation angle
{\draw[thick,rotate=#2] (#1) circle (10pt)
node[]{$\mathsf M$}
++(-12pt,3pt)--++(0,-6pt) --++(2.5pt,0) ++(-2.8pt,6pt)-- ++(2.5pt,0pt);
\draw[thick,rotate=#2] (#1) ++(12pt,3pt)--++(0,-6pt) --++(-2.5pt,0) ++(2.8pt,6pt)-- ++(-2.5pt,0pt);
}
\begin{document}
\begin{tikzpicture}[damper/.style={thick,
decorate,
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=10pt, draw=none] {};
\draw [thick] ($(dmp.north east)+(4pt,0)$) --
(dmp.south east) -- (dmp.south west) --
($(dmp.north west)+(4pt,0)$);
\draw [thick] ($(dmp.north)+(0,-8pt)$) --
($(dmp.north)+(0,8pt)$);
}}},]
\draw (0,2) to[R=$R_a$,o-, f=$i_a$] ++(2,0) to[L,cute inductor, l=$L_a$,] ++(2,0) to[sV, color=white, name=M1] ++(0,-2) to[short,-o] ++(-4,0);
\mymotor{M1}{90}
\draw (0,2) to [open, v=$E_a$] (0,0);
\draw[thick] (M1.north) -- ++(1.5,0) -- +(0,0.5) node [anchor=south] {$N_1$} -- +(0,-0.5) coordinate (N1);
\draw[->] ([xshift=7.5mm,yshift=-2mm]M1.north) to [out=-60,in=60, looseness=4] ++(0,0.4) node [above=1mm] {$T_m, \theta_m$};
\draw[thick] ([yshift=-2]N1) -- ++(0,-1.5) node [below] {$N_2$} ++(0,0.75) -- ++(1,0) node [cylinder, black, shape border rotate=180, draw,
minimum height=2, minimum width=1, aspect=0.5,cylinder uses custom fill, cylinder end fill = gray!20,anchor=west] (c) {Load Inertia};
\draw[->] ([xshift=-5mm,yshift=-2mm]c.west) to [out=-120,in=120, looseness=4] ++(0,0.4) node [above=1mm] {$\theta_L$};
\draw [damper] (c.east) -- node[above=3mm] {$d_1$} ++(0:2) ++(0,-1) coordinate (pttrn);
\draw[preaction={fill=gray!10},pattern=north east lines,pattern=bricks] (pttrn) rectangle ++(0.5,2);
\end{tikzpicture}
\end{document}
答案1
1
找到一种更优化的方法,将扭曲的箭头放置在垂直线和电机与气缸之间的中间
定义pic
并使用。
\tikzset{rotarrow/.pic={
\draw[thin,->] (-0.2,-0.2) to [out=-60,in=60, looseness=4] ++(0,0.4) node [above=1mm] {\tikzpictext};
},
}
% \draw (0,0) -- pic[pic text={$\theta$}]{rotarrow} ++(1.5,0); %<-use pic
2
在电阻器和电感器之间使用短路,并在那里使用流向箭头。
\draw (0,2) to[R=$R_a$,o-] ++(2,0) to[short,f=$i_a$] ++(0.1,0) to[L,cute inductor, l=$L_a$,] ++(2,0) to[sV, color=white, name=M1] ++(0,-2) to[short,-o] (0,0);
3
M1
是正弦电压源(sV
)。因此它试图访问的east
节点sV
不是mymotor
。您可以通过增加中的圆半径来修复它\mymotor
。或者您可以直接使用elmech
元素。
\draw (M1) node[elmech,scale=0.7]{M};
4
默认单位是pt
。请参阅以下问题:使用 shift 和 xshift 的不同维度和在 tikzpicture 中将“cm”设置为默认测量单位
5
使用 tikz 路径
\path (0,2)node[below]{+} -- node[midway]{$E_a$} (0,0)node[above]{-};
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{arrows,shapes,calc, positioning, patterns, decorations, decorations.markings,quotes}
\tikzset{rotarrow/.pic={
\draw[thin,->] (-0.2,-0.2) to [out=-60,in=60, looseness=4] ++(0,0.4) node [above=1mm] {\tikzpictext};
},
}
\begin{document}
\begin{tikzpicture}[damper/.style={thick,
decorate,
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=10pt, draw=none] {};
\draw [thick] ($(dmp.north east)+(4pt,0)$) --
(dmp.south east) -- (dmp.south west) --
($(dmp.north west)+(4pt,0)$);
\draw [thick] ($(dmp.north)+(0,-8pt)$) --
($(dmp.north)+(0,8pt)$);
}}},]
\draw (0,2) to[R=$R_a$,o-] ++(2,0) to[short,f=$i_a$] ++(0.1,0) to[L,cute inductor, l=$L_a$,] ++(2,0) to[short, name=M1] ++(0,-2) to[short,-o] (0,0);
\draw (M1) node[elmech,scale=0.7](M2){M};
\path (0,2)node[below]{+} -- node[midway]{$E_a$} (0,0)node[above]{-};
\draw[thick] (M2.east) -- pic[pic text={$T_m,\theta_m$}]{rotarrow} ++(1.5,0) -- +(0,0.5) node [anchor=south] {$N_1$} -- +(0,-0.5) coordinate (N1);
\draw[thick] ([yshift=-2]N1) -- ++(0,-1.5) node [below] {$N_2$} ++(0,0.75) -- pic[xscale=-1,pic text={$\theta_L$}]{rotarrow} ++(1,0) node [cylinder, black, shape border rotate=180, draw,
minimum height=2, minimum width=1, aspect=0.5,cylinder uses custom fill, cylinder end fill = black!70,anchor=west,xshift=-0.15cm, fill opacity=0.2,text opacity=1] (c) {Load Inertia};
\draw [damper] (c.east) -- node[above=3mm] {$d_1$} ++(0:2) node[draw, rectangle, minimum height=2cm, minimum width =0.5cm,anchor=west,preaction={fill=gray!10},pattern=north east lines,pattern=bricks]{};
\end{tikzpicture}
\end{document}