如何在 tikz 中添加圆圈并将节点与线的中间连接起来

如何在 tikz 中添加圆圈并将节点与线的中间连接起来

代码如下。

\documentclass[12pt,letterpaper]{article}    
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage{siunitx} % format SI units
\usepackage{tikz}  % for drawing pictures
\usetikzlibrary{arrows.meta,
                chains,
                positioning,
                quotes,
                shapes.geometric, arrows}
\usetikzlibrary{calc}

\begin{document}

\begin{center}
\begin{tikzpicture}[auto, 
                node distance = 15mm and 17mm,
                start chain = going right,
                arr/.style = {->},>=Latex,
                block/.style = {draw, minimum height=3em, minimum
                width=2em,align=center,fill=blue!20},
                sum/.style = {circle, draw, node contents={}},    
                        ]
                \begin{scope}[nodes={on chain, join=by arr}]        
                \coordinate (in);
                
             \node (n2) [block] {$X$} ;
             
                \node (n3) [block] {$K_a = 10^{3}$ \\ $\mathrm{V} \hspace{1mm} \mathrm{rad}^{-1}$} ;
                  
                \node (n4) [block] {$K_m = 2 \times 10^{-1}$ \\ $\mathrm{N} \hspace{1mm} \mathrm{m}  \hspace{1mm} \mathrm{V}^{-1}$} ;

            \node (n5) [block] {$K_s = 5 \times 10^{-2}$ \\ $\mathrm{rad} \hspace{1mm} N^{-1} m^{-1}$};
        
        
            \coordinate (out);
            \end{scope}

        \node [below=1pt of n3] {Amplifier};
          \node [below=1pt of n4] {Motor};
          \node [below=1pt of n5] {Spring};
          
        \node (n6)  [block, below=of n4] {$100$};
        \node [below=1pt of n6] {Transducer};
          
          \node at ($(n3.east)!.5!(n4.west)$) [label={above:$V$}, label={below:Volts}] {};
          \node at ($(n4.east)!.5!(n5.west)$) [label={above:$T$}, label={below:N m}] {};
        \node at ($(n5.east)!.5!(out)$) [label={above:$\theta$}, label={below:rad}] {};
        
        \node at ($(n2.west)!.5!(in)$) [label={above right:$+$}, label={below:$$}] {};


        
        % arrows and lines
        \draw[->]  (n5.east) -- ++ (12mm, 0) |- (n6.east) node[above left] {$$};
        \draw[->]  (n6.west) -- ++ (-6mm, 0) -| (n2.south) node[below left] {$-$};

             
   
                
\end{tikzpicture}
\end{center}

\end{document}

图片是我从中得到的。 在此处输入图片描述

这就是我想要做的。将第一个替换为里面有“x”的圆圈。 在此处输入图片描述

答案1

在方括号内的 tikzpicture 选项中将交叉样式添加到您的代码中

cross/.style={path picture={ 
                        \draw[black]
                        (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);
                }}

这将使十字架

现在添加以下代码,它将创建带有蓝色填充的圆圈

\node [draw,circle,fill=blue!20, cross,minimum width=1cm](n2){};

现在运行代码来获得完整的图片

平均能量损失

\documentclass[12pt,letterpaper]{article}    
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage{siunitx} % format SI units
\usepackage{tikz}  % for drawing pictures
\usetikzlibrary{arrows.meta,
    chains,
    positioning,
    quotes,
    shapes.geometric, arrows}
\usetikzlibrary{calc}

\begin{document}
    
    \begin{center}
        \begin{tikzpicture}[auto, 
            node distance = 15mm and 17mm,
            start chain = going right,
            arr/.style = {->},>=Latex,
            block/.style = {draw, minimum height=3em, minimum
                width=2em,align=center,fill=blue!20},
            sum/.style = {circle, draw, node contents={}},    
            cross/.style={path picture={ 
                    \draw[black]
                    (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);
            }}]
            \begin{scope}[nodes={on chain, join=by arr}]        
                \coordinate (in);
                
%               \node (n2) [block] {$X$} ;
                \node [draw,circle,fill=blue!20, cross,minimum width=1 cm](n2){};
                \node (n3) [block] {$K_a = 10^{3}$ \\ $\mathrm{V} \hspace{1mm} \mathrm{rad}^{-1}$} ;
                
                \node (n4) [block] {$K_m = 2 \times 10^{-1}$ \\ $\mathrm{N} \hspace{1mm} \mathrm{m}  \hspace{1mm} \mathrm{V}^{-1}$} ;
                
                \node (n5) [block] {$K_s = 5 \times 10^{-2}$ \\ $\mathrm{rad} \hspace{1mm} N^{-1} m^{-1}$};
                
                
                \coordinate (out);
            \end{scope}
            
            \node [below=1pt of n3] {Amplifier};
            \node [below=1pt of n4] {Motor};
            \node [below=1pt of n5] {Spring};
            
            \node (n6)  [block, below=of n4] {$100$};
            \node [below=1pt of n6] {Transducer};
            
            \node at ($(n3.east)!.5!(n4.west)$) [label={above:$V$}, label={below:Volts}] {};
            \node at ($(n4.east)!.5!(n5.west)$) [label={above:$T$}, label={below:N m}] {};
            \node at ($(n5.east)!.5!(out)$) [label={above:$\theta$}, label={below:rad}] {};
            
            \node at ($(n2.west)!.5!(in)$) [label={above right:$+$}, label={below:$$}] {};
            
            
            
            % arrows and lines
            \draw[->]  (n5.east) -- ++ (12mm, 0) |- (n6.east) node[above left] {$$};
            \draw[->]  (n6.west) -- ++ (-6mm, 0) -| (n2.south) node[below left] {$-$};
            
            
            
            
        \end{tikzpicture}
    \end{center}
    
\end{document}

在此处输入图片描述

相关内容