箭未触及方块

箭未触及方块

我目前正在绘制下图:

在此处输入图片描述

由于某种原因,其中一个箭头没有接触到块 IFOC。我该如何修复?

我的代码:

\documentclass[tikz,border=2pt]{standalone}

% Inclui subpacotes
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{babel}
\usetikzlibrary{calc,arrows.meta,patterns,backgrounds}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}

% Define subcomandos
\tikzstyle{line} = [draw, -latex']
\tikzstyle{block} = [draw, rectangle, rounded corners, minimum size=1cm, text centered]
\tikzstyle{circulo} = [draw, circle, minimum size=0.7cm, text centered]
\tikzstyle{triangulo} = [draw, thick, isosceles triangle, minimum height=1cm, isosceles triangle apex angle=60]
\tikzstyle{joint} = [draw, circle, fill, inner sep=0pt, minimum size=3pt]

\begin{document}

\tikzset{pics/transform/.style 2 args={code={%
\path (-\pgfkeysvalueof{/tikz/transform/width}/2,\pgfkeysvalueof{/tikz/transform/height}/2)
 node[below right] (tl) {#2}
 rectangle
(\pgfkeysvalueof{/tikz/transform/width}/2,-\pgfkeysvalueof{/tikz/transform/height}/2)
 node[above left] (br) {#1};
 \node[pic actions,inner sep=0pt,fit=(tl)(br),path picture={\path[pic actions]
 (path picture bounding box.north east)
 -- (path picture bounding box.south west);}] 
 (\pgfkeysvalueof{/tikz/transform/name}){};
}},transform/.cd,height/.initial=2cm,width/.initial=2cm,name/.initial=}

\tikzset{pics/inverter/.style 2 args={code={%
\path (-\pgfkeysvalueof{/tikz/inverter/width}/2,-\pgfkeysvalueof{/tikz/inverter/height}/2)
 node[above right,scale=2] (bl) {#2}
 rectangle
(\pgfkeysvalueof{/tikz/inverter/width}/2,\pgfkeysvalueof{/tikz/inverter/height}/2)
 node[below left,scale=2] (tr) {#1};
 \node[pic actions,inner sep=0pt,fit=(bl)(tr),path picture={\path[pic actions]
 (path picture bounding box.north west)
 -- (path picture bounding box.south east);}] 
 (\pgfkeysvalueof{/tikz/inverter/name}){};
 \node at (0,\pgfkeysvalueof{/tikz/inverter/height}/2) 
 [rectangle, above]{\pgfkeysvalueof{/tikz/inverter/title}};
}},inverter/.cd,height/.initial=2cm,width/.initial=2cm,name/.initial=,%
title/.initial=PWM Inverter}

\begin{tikzpicture}[auto, node distance=2cm, >=latex']
\path pic[draw,rounded corners,text centered,transform/name=trans1] {transform={$abc$}{$qd0$}}
(0,-3) pic[draw,rounded corners,text centered,transform/name=trans2] {transform={$abc$}{$qd0$}}
(-3,0) node[block,minimum size=2cm](ifoc){IFOC};
\node at (0,-1.5) [joint](j4){};

% arrows
\draw[->] (-2,0.35)-- node{$v_{qs}^{\lambda}$} (-1,0.35);
\draw[->] (-2,-0.35)-- node{$v_{ds}^{\lambda}$} (-1,-0.35);
\draw[->] (-1,-2.65)-|node[above,pos = 0.15873]{$i_{qs}^{\lambda}$}(-2.5,-1);
\draw[->] (-1,-3.35)-|node[above,pos = 0.11494]{$i_{ds}^{\lambda}$}(-3.0,-1);
\draw[->] (ifoc)--(-1.5,-1.5)-|node[above,pos = 0.35]{$\theta^{\lambda}$}(trans1);
\draw[->] (j4)--(trans2);
\end{tikzpicture}
\end{document}

答案1

正如评论中提到的,间隙是由于圆角造成的。解决该问题的一种方法是计算节点边界路径与到中心的线的延伸的交点。如果您想用箭头终止线,此方法也有效,否则您只需使用clip

\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{arrows}
\usetikzlibrary{fit}
\usetikzlibrary{intersections}
\usetikzlibrary{positioning}

% Define styles: use \tikzset !
\tikzset{block/.style={draw, rectangle, rounded corners, minimum size=1cm, text
centered},
joint/.style={draw, circle, fill, inner sep=0pt, minimum size=3pt}}

\begin{document}

\tikzset{pics/transform/.style 2 args={code={%
\path (-\pgfkeysvalueof{/tikz/transform/width}/2,\pgfkeysvalueof{/tikz/transform/height}/2)
 node[below right] (tl) {#2}
 rectangle
(\pgfkeysvalueof{/tikz/transform/width}/2,-\pgfkeysvalueof{/tikz/transform/height}/2)
 node[above left] (br) {#1};
 \node[pic actions,inner sep=0pt,fit=(tl)(br),path picture={\path[pic actions]
 (path picture bounding box.north east)
 -- (path picture bounding box.south west);}] 
 (\pgfkeysvalueof{/tikz/transform/name}){};
}},transform/.cd,height/.initial=2cm,width/.initial=2cm,name/.initial=}

\tikzset{pics/inverter/.style 2 args={code={%
\path (-\pgfkeysvalueof{/tikz/inverter/width}/2,-\pgfkeysvalueof{/tikz/inverter/height}/2)
 node[above right,scale=2] (bl) {#2}
 rectangle
(\pgfkeysvalueof{/tikz/inverter/width}/2,\pgfkeysvalueof{/tikz/inverter/height}/2)
 node[below left,scale=2] (tr) {#1};
 \node[pic actions,inner sep=0pt,fit=(bl)(tr),path picture={\path[pic actions]
 (path picture bounding box.north west)
 -- (path picture bounding box.south east);}] 
 (\pgfkeysvalueof{/tikz/inverter/name}){};
 \node at (0,\pgfkeysvalueof{/tikz/inverter/height}/2) 
 [rectangle, above]{\pgfkeysvalueof{/tikz/inverter/title}};
}},inverter/.cd,height/.initial=2cm,width/.initial=2cm,name/.initial=,%
title/.initial=PWM Inverter}

\begin{tikzpicture}[auto, node distance=2cm, >=latex']
\path pic[draw,rounded corners,text centered,transform/name=trans1] {transform={$abc$}{$qd0$}}
 (0,-3) pic[draw,rounded corners,text centered,transform/name=trans2]{transform={$abc$}{$qd0$}}
 (-3,0) node[block,minimum size=2cm,name path=block](ifoc){IFOC};
\node at (0,-1.5) [joint](j4){};

% arrows
\draw[->] (-2,0.35)-- node{$v_{qs}^{\lambda}$} (-1,0.35);
\draw[->] (-2,-0.35)-- node{$v_{ds}^{\lambda}$} (-1,-0.35);
\draw[->] (-1,-2.65)-|node[above,pos = 0.15873]{$i_{qs}^{\lambda}$}(-2.5,-1);
\draw[->] (-1,-3.35)-|node[above,pos = 0.11494]{$i_{ds}^{\lambda}$}(-3.0,-1);
\path[name path=line] (ifoc.center) --(-1.5,-1.5);
\draw[name intersections={of=block and line},->] (intersection-1)--(-1.5,-1.5)-|node[above,pos = 0.35]{$\theta^{\lambda}$}(trans1);
\draw[->] (j4)--(trans2);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容