是否可以在 Tikz 中绘制这种形状?
它是框图中的一个积分器块。
答案1
您可以使用/.pic
构造来执行此操作。在环境中绘制所需的元素(积分器、微分器等)picture
,然后将这些图片像节点一样插入到您想要的任何位置。这是一个尝试(无意义的块只是为了展示方法):
\documentclass[border=1mm,tikz]{standalone}
\usetikzlibrary{calc,positioning}
\begin{document}
\tikzset{integ/.pic={
\draw [blue,fill=green!30](0,2.5)rectangle(1,-2.5) (1,2.5)--(6,0)--(1,-2.5)--cycle node at (1.5,0) {$\displaystyle \int$};
}, dif/.pic={
\node at (0,0) [blue, fill=green!30, draw,rectangle, minimum size=1.2cm] {$\displaystyle \frac{d}{dt}$};}}
\begin{tikzpicture}[nd/.style={draw, circle,inner sep=0pt,minimum size=4pt}]
\path (0,0) node (in) [nd,label={left:Input}]{} node (out) [nd,label={right:Output},right=6.5cm of in]{};
\path [draw] (in)--(out) (in) pic [right=of in, scale=0.3]{integ} (in) pic [right=4cm of in, scale=1]{dif} node(ff){};
\end{tikzpicture}
\end{document}
输出结果如下:
对于按照 OP 评论的系统,我们可以这样做:
\documentclass[border=.2mm,tikz]{standalone}
\usetikzlibrary{calc,positioning}
\begin{document}
\tikzset{integ/.pic={
\draw [fill=blue!10](0,2.5)rectangle(1,-2.5) (1,2.5)--(6,0)--(1,-2.5)--cycle node at (1.5,0) {};}}
\small
\begin{tikzpicture}[>=stealth,nd/.style={draw,fill=blue!10,circle,inner sep=0pt,minimum size=5pt}, blk/.style={draw,fill=blue!10,minimum height=0.8cm,text width=1.5cm, text centered}]
\path (0,0)coordinate(in) node(dif)[nd,right=.7cm of in,label=below left:$-$]{} node(Reg)[blk,right=of dif]{Regulator} coordinate[below right=of Reg](intg) node(sys)[blk,right=of Reg]{System} node(Dis)[above=.5cm of sys]{Disturbances} node(out)[right=of sys]{} node(y)at($(sys)!.65!(out)$)[above]{$y$};
\draw[->] (in)--node[above]{$r$}(dif);
\draw[->](dif)--node[above]{$e$}(Reg);
\draw[->](Reg)--node[above]{$u$}(sys);
\draw[->](sys)--(out);
\draw[->](Dis)--(sys);
\draw[->] (y)|- (intg);
\draw[->] (intg)-| node[above left,yshift=.5cm]{$y_m$}(dif);
\path (intg) pic[scale=0.17,rotate=180,outer sep =0pt] {integ};
\end{tikzpicture}
\end{document}
现在有以下输出: