Erros do modificador de distância do cálculo Tikz em linhas giradas na matriz

Erros do modificador de distância do cálculo Tikz em linhas giradas na matriz

Quero ilustrar como agrupar certos termos em uma tabela infinita. Até agora eu fiz isso:

insira a descrição da imagem aqui

Também quero agrupar a₂b₃ com a₃b₂ e fazer outro grupo para a₃b₃. Até agora eu fiz as linhas com pontas pontilhadas com base em outras respostas de troca de pilha Texaquieaqui. O exemplo acima foi feito usando o seguinte código:

\documentclass{article}

\usepackage{etoolbox}
\usepackage{tikz} 
\usetikzlibrary{positioning, fit, matrix, decorations.pathreplacing, calc}

\tikzset{%
  rect/.style n args={4}{
        draw=none,
        rectangle,
        append after command={
            \pgfextra{%
                \pgfkeysgetvalue{/pgf/outer xsep}{\oxsep}
                \pgfkeysgetvalue{/pgf/outer ysep}{\oysep}
                \def\arg@one{#1}
                \def\arg@two{#2}
                \def\arg@three{#3}
                \def\arg@four{#4}
                \begin{pgfinterruptpath}
                    \ifx\\#1\\\else
                        \draw[draw,#1] ([xshift=-\oxsep,yshift=+\pgflinewidth]\tikzlastnode.south east) edge[decorate] ([xshift=-\oxsep,yshift=0\ifx\arg@two\@empty-\pgflinewidth\fi]\tikzlastnode.north east);
                    \fi\ifx\\#2\\\else
                        \draw[draw,#2] ([xshift=-\pgflinewidth,yshift=-\oysep]\tikzlastnode.north east) edge[decorate] ([xshift=0\ifx\arg@three\@empty+\pgflinewidth\fi,yshift=-\oysep]\tikzlastnode.north west);
                    \fi\ifx\\#3\\\else
                        \draw[draw,#3] ([xshift=\oxsep,yshift=0-\pgflinewidth]\tikzlastnode.north west) edge[decorate] ([xshift=\oxsep,yshift=0\ifx\arg@four\@empty+\pgflinewidth\fi]\tikzlastnode.south west);
                    \fi\ifx\\#4\\\else
                        \draw[draw,#4] ([xshift=0+\pgflinewidth,yshift=\oysep]\tikzlastnode.south west) edge[decorate] ([xshift=0\ifx\arg@one\@empty-\pgflinewidth\fi,yshift=\oysep]\tikzlastnode.south east);
                    \fi
                \end{pgfinterruptpath}
            }
        }
    },
    dotted ends/.style={
        decoration={
            show path construction,
            lineto code={
                \draw[dashed,#1] (\tikzinputsegmentfirst) --($(\tikzinputsegmentfirst)!-.2!(\tikzinputsegmentlast)$);,
                \draw (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);,
                \draw[dashed,#1] (\tikzinputsegmentlast) -- ($(\tikzinputsegmentlast)!-.2!(\tikzinputsegmentfirst)$);,
            }
        },
        decorate
    },
}



\begin{document}

\begin{center}    
    \begin{tikzpicture}
        \matrix[
            matrix of nodes,
            inner sep=20pt,
            row sep=2mm,
            column sep=2mm,
            every node/.style={
                circle,
                inner sep=0pt,
                align=center,
                text width=3em,
                text height=0.8em,
                text depth=0.2em,
            }] (m) {
                $a_0b_0$ & $a_0b_1$ & $a_0b_2$ & $a_0b_3$ & $\cdots$ \\
                $a_1b_0$ & $a_1b_1$ & $a_1b_2$ & $a_1b_3$ & $\cdots$ \\
                $a_2b_0$ & $a_2b_1$ & $a_2b_2$ & $a_2b_3$ & $\cdots$ \\
                $a_3b_0$ & $a_3b_1$ & $a_3b_2$ & $a_3b_3$ & $\cdots$ \\
                $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ \\
            };
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-1) (m-1-1)}
            ] {};
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-2) (m-2-1)}
            ] {};
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-3) (m-3-1)}
            ] {};
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-4) (m-4-1)}
            ] {};
            \node[
                inner sep=0pt,
                rotate fit=-45,
                fit={(m-2-4) (m-4-2)},
                rect={thick, blue, dotted ends={thick}}{}{thick, blue, dotted ends={thick}}{}
            ] {};
    \end{tikzpicture}
\end{center}

\end{document}

Porém, ao aplicar o dotted-endsestilo aos 2 últimos grupos resulta em linhas tracejadas mais curtas no final:

insira a descrição da imagem aqui

Eu tentei corrigir isso substituindo ($(\tikzinputsegmentfirst)!-.2!(\tikzinputsegmentlast)$)por ($(\tikzinputsegmentfirst)!-1cm!(\tikzinputsegmentlast)$). No entanto, isso resultou em alguns erros, e as linhas agora ficam assim:

insira a descrição da imagem aqui

Como faço para corrigir isso?

informação relacionada