使用检查器方法进行交叉乘积

使用检查器方法进行交叉乘积

我看到了一个关于如何使用箭头在矩阵内获取箭头的老问题。感谢 Altermundus,我能够破解以下文件:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{fullpage,amsmath}
\begin{document}

\begin{align*}
\begin{array}{|rrr|rr}
i &  j & k & i &  j\\
3 & -2 & 2 & 3 & -2\\
3 &  2 & 1 & 3 &  2
\end{array}
\end{align*}

\begin{figure}[!htbp]
\tikzset{node style ge/.style={circle}}
\centering
\begin{tikzpicture}[baseline=(A.center)]
  \tikzset{BarreStyle/.style =   {opacity=.4,line width=3 mm,line cap=round,color=#1}}
  \tikzset{SignePlus/.style  =   {above left,,opacity=0.8,circle,fill=#1!50}}
  \tikzset{SigneMoins/.style =   {above right,,opacity=0.8,circle,fill=#1!50}}
% les matrices
\matrix (A) [matrix of math nodes, nodes = {node style ge},,column sep=0 mm] 
{      i &  j & k & i &  j \\
       3 & -2 & 2 & 3 & -2 \\
       3 &  2 & 1 & 3 &  2 \\
};

 \draw [BarreStyle=red] (A-1-1.north west) node[SignePlus=red] {$+$} to (A-3-3.south east) ;
 \draw [BarreStyle=red] (A-1-2.north west) node[SignePlus=red] {$+$} to (A-3-4.south east) ;
 \draw [BarreStyle=red] (A-1-3.north west) node[SignePlus=red] {$+$} to (A-3-5.south east) ;
 \draw [BarreStyle=blue]  (A-1-3.north east) node[SigneMoins=blue] {$-$} to (A-3-1.south west);
 \draw [BarreStyle=blue]  (A-1-4.north east) node[SigneMoins=blue] {$-$} to (A-3-2.south west);
 \draw [BarreStyle=blue]  (A-1-5.north east) node[SigneMoins=blue] {$-$} to (A-3-3.south west);
 \draw (A-1-1.north west) -- (A-3-1.south west); \draw (A-1-3.north east) -- (A-3-3.south east);
\end{tikzpicture}
\end{figure}

\end{document}

叉积

现在我需要整理几个铺位,如果能有人帮忙我将非常感激 =)

  • 有什么方法可以让绝对符号(例如矩阵周围的括号)| |保持水平吗?目前,由于a_{11}和的大小不同,它们是倾斜的$_{13}

  • 蓝线和红线也不太平行,有什么解决办法吗?

我原本想将这段代码包装在一个新的环境中,或者其他什么地方。但我想这得留到以后再回答。我有点需要做这些,所以我宁愿不要只在这种情况下使用快速而粗糙的修复方法。我的输入从不超过 3 位数字。

答案1

以下是一些可以(希望)改善结果的修改:

  1. 我为矩阵节点中的文本声明了固定宽度。
  2. 我使用let语法来绘制垂直规则。
  3. 我降低了inner sep包含符号的节点的值。
  4. 我定义了一个\checkers带有强制参数(矩阵名称)的命令来绘制设计。事实上,整个构造可能使用七个参数的命令。

以下是代码

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\usepackage{fullpage,amsmath}

\newcommand\checkers[1]{%
 \draw [BarreStyle=red] (#1-1-1.120) node[SignePlus=red] {$+$} to (#1-3-3.320) ;
 \draw [BarreStyle=red] (#1-1-2.120) node[SignePlus=red] {$+$} to (#1-3-4.320) ;
 \draw [BarreStyle=red] (#1-1-3.120) node[SignePlus=red] {$+$} to (#1-3-5.320) ;
 \draw [BarreStyle=blue]  (#1-1-3.35) node[SigneMoins=blue] {$-$} to (#1-3-1.230);
 \draw [BarreStyle=blue]  (#1-1-4.35) node[SigneMoins=blue] {$-$} to (#1-3-2.230);
 \draw [BarreStyle=blue]  (#1-1-5.35) node[SigneMoins=blue] {$-$} to (#1-3-3.230);
 \draw let \p1 = (#1-3-3.south east), \p2 = ( $ (#1-1-3.north east)!.5!(#1-1-4.north) $ ) in (\p2) -- (\x2,\y1);
 \draw let \p1 = (#1-1-1.north west), \p2 = (#1-3-1.south west) in (\p2) -- (\x2,\y1);
}
\tikzset{BarreStyle/.style =   {opacity=.4,line width=4mm,line cap=round,color=#1}}
\tikzset{SignePlus/.style  =   {above left,,opacity=0.8,circle,inner sep=1pt,fill=#1!50}}
\tikzset{SigneMoins/.style =   {above right,,opacity=0.8,circle,inner sep=1pt,fill=#1!50}}

\begin{document}

\begin{figure}
\tikzset{node style ge/.style={circle}}
\centering
\begin{tikzpicture}[baseline=(A.center)]
\matrix (A) [matrix of math nodes, nodes = {node style ge},column sep=0 mm,nodes={text width=1em,align=right}] 
{      i &  j & k & i &  j \\
       3 & -2 & 2 & 3 & -2 \\
       31 &  2 & 61 & 3 &  2 \\
};
\checkers{A}
\end{tikzpicture}\\[1em]
\begin{tikzpicture}[baseline=(B.center)]
\matrix (B) [matrix of math nodes, nodes = {node style ge},column sep=0 mm,nodes={text width=1em,align=right}] 
{      i &  j & k & i &  j \\
       13 & -2 & 25 & 13 & -2 \\
       3 &  -18 & 1 & 3 &  2 \\
};
\checkers{B}
\end{tikzpicture}
\end{figure}

\end{document}

在此处输入图片描述

如果这将始终用于表示交叉积,则可以定义一个具有七个参数(六个坐标和矩阵名称)的命令;类似于以下内容:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\usepackage{fullpage,amsmath}

\newcommand\checkers[7]{%
\begin{tikzpicture}[baseline=(#1.center)]
\tikzset{BarreStyle/.style =   {opacity=.4,line width=4mm,line cap=round,color=##1}}
\tikzset{SignePlus/.style  =   {above left,opacity=0.8,circle,inner sep=1pt,fill=##1!50}}
\tikzset{SigneMoins/.style =   {above right,opacity=0.8,circle,inner sep=1pt,fill=##1!50}}
\tikzset{node style ge/.style={circle}}

\matrix (#1) [matrix of math nodes, nodes = {node style ge},column sep=0 mm,nodes={text width=1.8em,align=right,font=\footnotesize},ampersand replacement = \&] 
{      i \&  j \& k \& i \&  j \\
       #2 \& #3 \& #4 \& #2 \& #3 \\
       #5 \&  #6 \& #7 \& #5 \&  #6 \\
};
\draw [BarreStyle=red] (#1-1-1.120) node[SignePlus=red] {$+$} to (#1-3-3.320) ;
\draw [BarreStyle=red] (#1-1-2.120) node[SignePlus=red] {$+$} to (#1-3-4.320) ;
\draw [BarreStyle=red] (#1-1-3.120) node[SignePlus=red] {$+$} to (#1-3-5.320) ;
\draw [BarreStyle=blue]  (#1-1-3.35) node[SigneMoins=blue] {$-$} to (#1-3-1.230);
\draw [BarreStyle=blue]  (#1-1-4.35) node[SigneMoins=blue] {$-$} to (#1-3-2.230);
\draw [BarreStyle=blue]  (#1-1-5.35) node[SigneMoins=blue] {$-$} to (#1-3-3.230);
\draw let \p1 = (#1-3-3.south east), \p2 = ( $ (#1-1-3.north east)!.5!(#1-1-4.north) $ ) in (\p2) -- (\x2,\y1);
\draw let \p1 = (#1-1-1.north west), \p2 = (#1-3-1.south west) in (\p2) -- (\x2,\y1);\end{tikzpicture}
}

\begin{document}

\begin{figure}
\centering
\checkers{A}{3}{-2}{2}{31}{2}{61}\\[1em]
\checkers{B}{13}{-2}{25}{3}{-18}{1}
\end{figure}

\end{document}

答案2

只是使用 和 的另一种fit解决rotate fit方案pgfonlayer......

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,matrix,backgrounds,fit}
\usepackage{amsmath}

\newcommand\checkers[1]{
  \begin{pgfonlayer}{background}
    \tikzset{
      bar style/.style={inner ysep=-.1em,inner xsep=1em,rounded corners=.8em},
      fillop/.style={fill=##1,fill opacity=.3},
      sign/.style={circle,inner sep=.2em,fillop=##1,text opacity=1},
    }
    \foreach \posa in {1,2,3}{
      \pgfmathsetmacro{\posb}{\posa + 2}
      \node[bar style=red,rotate fit=-45,
      fit=(#1-1-\posa)(#1-3-\posb),fillop=red,
      label={[sign=red]west:$+$}]{};
      \node[bar style=red,rotate fit=45,
      fit=(#1-1-\posb)(#1-3-\posa),fillop=blue,
      label={[sign=blue]east:$-$}]{};
    }
    \draw let \p1=($(#1-1-3)!.5!(#1-1-4)$) in
    (\p1 |- #1.north) -- (\p1 |- #1.south);
    \draw (#1.north west) -- (#1.south west);
  \end{pgfonlayer}
}

\begin{document}
\begin{tikzpicture}
  \matrix (A)
  [matrix of math nodes,inner sep=0pt,
  nodes={minimum size=2.5em,inner sep=0pt}] 
  {
    i  & j  & k  & i & j  \\
    3  & -2 & 2  & 3 & -2 \\
    61 & 2  & 61 & 3 & 2  \\
  };
  \checkers{A}
\end{tikzpicture}

{\footnotesize%
  \begin{tikzpicture}
    \matrix (B)
    [matrix of math nodes,inner sep=0pt,
    nodes={minimum size=2.5em,inner sep=0pt}] 
    {
      i  & j   & k  & i  & j  \\
      13 & -2  & 125 & 13 & -2 \\
      3  & -18 & 1  & 3  & 2  \\
    };
    \checkers{B}
  \end{tikzpicture}%
}
\end{document}

以下是不同字体大小的结果:

在此处输入图片描述

答案3

它不是很性感,但是很容易。

\begin{tikzpicture}[baseline=(A.center)]
 \tikzset{BarreStyle/.style ={opacity=.4,line width=4 mm,line cap=round,color=#1!50}}
 \tikzset{SignePlus/.style = {above left,,opacity=1,circle,fill=#1!20}}
 \tikzset{SigneMoins/.style =   {below left,,opacity=1,circle,fill=#1!20}}
\matrix (A) [matrix of math nodes, nodes = {node style ge},,column sep=0 mm] 
{ \phantom{A} & \phantom{A} & \phantom{A} \\
  \phantom{A} & \phantom{A} & \phantom{A} \\
 \phantom{A} & \phantom{A} & \phantom{A} \\
 \phantom{A} & \phantom{A} & \phantom{A} \\
  \phantom{A} & \phantom{A} & \phantom{A} \\
};

 \draw [BarreStyle=blue] (A-1-1.north west) to (A-3-3.south east);
 \draw [BarreStyle=blue] (A-2-1.north west) to (A-4-3.south east) ;
 \draw [BarreStyle=blue] (A-3-1.north west) to (A-5-3.south east) ;

 \draw [BarreStyle=red]  (A-3-1.south west)  to (A-1-3.north east);
 \draw [BarreStyle=red]  (A-4-1.south west)  to (A-2-3.north east);
 \draw [BarreStyle=red]  (A-5-1.south west)  to (A-3-3.north east);

 \draw (A-1-1.north west) node[SignePlus=blue] {$+$};
 \draw (A-2-1.north west) node[SignePlus=blue] {$+$};
 \draw (A-3-1.north west) node[SignePlus=blue] {$+$};
 \draw (A-3-1.south west) node[SigneMoins=red] {$-$};
 \draw (A-4-1.south west) node[SigneMoins=red] {$-$};
 \draw (A-5-1.south west) node[SigneMoins=red] {$-$};

 \matrix (A) [matrix of math nodes, nodes = {node style ge},,column sep=0 mm] 
 { a & b & c \\
   d & e & f \\
   g & h & i \\
   a & b & c \\
   d & e & f \\
 };
\end{tikzpicture}

相关内容