数学多米诺骨牌

数学多米诺骨牌

我想制作我自己版本的多米诺骨牌游戏,但我不知道如何使用 tikz 制作。编辑:更准确地说,我不知道如何创建具有粗边框和细边框的矩形,以及如何将细灰色矩形放置在带有方程式的矩形的边框上。有什么建议吗? 二次方程的多米诺骨牌

答案1

这是其中一种方法。我pic为多米诺骨牌制作了一个带有三个参数的模型:文本(方程式)和底部细长矩形的位置。我还创建了尺寸参数,这样图片就很容易定制了。

代码:

\documentclass[tikz,border=2mm]{standalone}
\usepackage{pifont} % scissors: \ding{34}

% paramaters
\def\W{4}    % domino width
\def\H{5.5}  % domino height
\def\w{2.75} % (horizontal) thin rectangle width
\def\h{0.2}  % (horizontal) thin rectangle height
\def\tw{2.8} % text width

\tikzset
{%
    pics/domino/.style n args={3}{
    % USAGE:
    % #1 = top text
    % #2 = bottom text
    % #3 = bottom thin rectangle, 0 bottom / 1 left
    code={%
      \draw[line width=0.4mm] (0,0) rectangle (\W,\H);
      \draw (0,0.5*\H) -- (\W,0.5*\H);
      \node[text width=\tw cm,align=center] at (0.5*\W,0.75*\H) {#1};
      \node[text width=\tw cm,align=center] at (0.5*\W,0.25*\H) {#2};
      \draw (0,\H-\h) -| (\w,\H);
      \ifnum#3 = 0
        \draw (0,\h) -| (\w,0);
      \else
        \draw (\W-\h,0) -- (\W-\h,0.5*\H);
      \fi
    }},
}

\begin{document}
\begin{tikzpicture}
\draw[dashed] (0,0) -- (-1,0) node [left] {\ding{34}};
\pic at (0,0)     {domino={$x^2+4x+4=0$}{$(x+1)^2=0$}{0}};
\pic at (\W,0)    {domino={$x^2-x+6=0$}{$(x+2)^2=0$}{0}};
\pic at (2*\W,0)  {domino={$2x^2-6x-20=0$}{$(x+2)(x+5)=0$}{1}};
\pic at (3*\W,0)  {domino={$x^2+x-6=0$}{$3(x-1)(x+1)=0$}{0}};
\pic at (0,\H)    {domino={$x^2-x-6=0$}{$(x-2)(x+3)=0$}{1}};
\pic at (\W,\H)   {domino={$x^2+2x+1=0$}{$(x-3)(x+2)=0$}{0}};
\pic at (2*\W,\H) {domino={$x^2+4x-21=0$}{\sffamily Die Gleichung lässt sich nicth in Linearfaktoren zerlegen}{1}};
\pic at (3*\W,\H) {domino={$x^2+7x+10=0$}{$(x+7)(x-3)=0$}{0}};
\end{tikzpicture}
\end{document}

还有多米诺骨牌: 在此处输入图片描述

答案2

我修改了 Juan Castaño 的代码,这样细方块就可以放在任何角落。以下是我对完整多米诺骨牌的修改:

\documentclass[tikz,border=2mm]{standalone}
\usepackage{pifont} % scissors: \ding{34}
\usepackage[ngerman]{babel}

% paramaters
\def\lw{0.05} % line width
\def\sh{0.5*\lw} % half line width for shifting the thin rectangles
\def\W{4}    % domino width
\def\H{5.5}  % domino height
\def\w{0.5*\H-0.5*\lw} % (horizontal) thin rectangle width
\def\h{0.11}  % (horizontal) thin rectangle height
\def\tw{3.4} % text width

\tikzset
{%
    pics/domino/.style n args={4}{
    % USAGE:
    % #1 = top text
    % #2 = top thin rectangle, 0 left / 1 top left / 2 top right / 3 right
    % #3 = bottom text
    % #4 = bottom thin rectangle, 0 left / 1 bottom left / 2 bottom right / 3 right
    code={%
        \draw[line width=\lw cm] (0,0) rectangle (\W,\H);
        \draw (0,0.5*\H) -- (\W,0.5*\H); % center line
        \node[text width=\tw cm,align=center] at (0.5*\W,0.75*\H) {#1};
        \ifnum#2 = 0
        \draw[fill=gray!50] (\sh,\w+\sh) rectangle ++(\h,\w);
            \else\ifnum#2 = 1
            \draw[fill=gray!50] (\sh,\H-\h-\sh  ) rectangle ++(\w,\h);
                \else\ifnum#2 = 2
                \draw[fill=gray!50] (\W-\w+\sh,\H-\h-\sh) rectangle ++(\w,\h);
                    \else\ifnum#2 = 3
                    \draw[fill=gray!50] (\W-\h-\sh,\w+\sh) rectangle ++(\h,\w);
                    \fi
                \fi
            \fi
        \fi
    \node[text width=\tw cm,align=center] at (0.5*\W,0.25*\H) {#3};
    \ifnum#4 = 0
    \draw[fill=gray!50] (\sh,\sh) rectangle ++(\h,\w);
        \else\ifnum#4 = 1
        \draw[fill=gray!50] (\sh,\sh) rectangle ++(\w,\h);
            \else\ifnum#4 = 2
            \draw[fill=gray!50] (\W-\w+\sh,\sh) rectangle ++(\w,\h);
                \else\ifnum#4 = 3
                \draw[fill=gray!50] (\W-\h-\sh,+\sh) rectangle ++(\h,\w);
                \fi
            \fi
        \fi
    \fi
    }},
}

\begin{document}
\begin{tikzpicture}
\draw[dashed] (0,\H) -- (-1,\H) node [left] {\ding{34}};
\pic at (0,0)     {domino={$x^2-x-6=0$}{1}{$(x-2)(x+3)=0$}{3}};
\pic at (\W,0)    {domino={$x^2+2x+1=0$}{1}{$(x-3)(x+2)=0$}{1}};
\pic at (2*\W,0)  {domino={$x^2+4x-21=0$}{1}{\sffamily Die Gleichung lässt sich nicht in Linear\-faktoren zerlegen}{3}};
\pic at (3*\W,0)  {domino={$x^2+7x+10=0$}{1}{$(x+7)(x-3)=0$}{1}};

\pic at (0,-\H)    {domino={$x^2+4x+4=0$}{1}{$(x+1)^2=0$}{1}};
\pic at (\W,-\H)   {domino={$x^2-x+6=0$}{1}{$(x+2)^2=0$}{1}};
\pic at (2*\W,-\H) {domino={$2x^2-6x-20=0$}{1}{$(x+2)(x+5)=0$}{3}};
\pic at (3*\W,-\H) {domino={$x^2+x-6=0$}{1}{$3(x-1)(x+1)=0$}{1}};

\pic at (0,-2*\H)   {domino={$3x^2-3=0$}{1}{$(x-2)(x-3)=0$}{3}};
\pic at (\W,-2*\H)  {domino={$x^2-16=0$}{2}{$2(x+2)(x-5)=0$}{3}};
\pic at (2*\W,-2*\H)    {domino={$x^2-7x-18=0$}{2}{$(x-4)(x+4)=0$}{0}};
\pic at (3*\W,-2*\H)    {domino={$x^2-9x+18=0$}{2}{$(x-9)(x+2)=0$}{2}};

\pic at (0,-3*\H)   {domino={$x^2+\frac{3}{2}x+\frac{1}{2}=0$}{1}{$(x-3)(x-6)=0$}{0}};

\pic at (\W,-3*\H)  {domino={$x^2-5x+6=0$}{1}{$\left(x+\frac{1}{2}\right(x+1)=0$}{3}};

\end{tikzpicture}
\end{document}

它看起来是这样的:

完成多米诺骨牌

相关内容