用平面切割钢筋(tikz,3D)

用平面切割钢筋(tikz,3D)

如何用红色飞机逼真地绘制一条被切成两半的灰色条带?我的想法是将一些碎片画在另一层上。但这里的接缝变得丑陋。也许还有其他巧妙的方法?

\documentclass[tikz]{standalone}
\usetikzlibrary{3d}

\begin{document}

\pgfdeclarelayer{bg}    % declare background layer
\pgfdeclarelayer{layer1}
\pgfdeclarelayer{layer2}
\pgfdeclarelayer{layer3}
\pgfsetlayers{layer1,layer2,layer3,bg,main}  % set the order of the layers (main is the standard layer)

\begin{tikzpicture}
    %    \draw[red] (0,0,0) -- (0,0,1) ;
    %    \draw[blue] (0,0,0) -- (2,0,0);

    \begin{scope}[canvas is yz plane at x=1]
        \draw[line join=round, thick, fill=black!20, thin] (-1,-1) rectangle (1,1);
    \end{scope}
    \begin{pgfonlayer}{layer3}
        \begin{scope}[canvas is yz plane at x=0.9]
            \draw[line join=round, thick, fill=red!50,opacity=0.5] (-1.5,-1.5) rectangle (1.5,1.5);
        \end{scope}
    \end{pgfonlayer}
    \begin{scope}[canvas is xy plane at z=1]
        \draw[line join=round, thick, fill=black!40, thin] (1,1) rectangle ++(-0.1,-2);
        \draw[dashed, black!40, thick] (0.9,-1) -- ++(0,2);
    \end{scope}
    \begin{pgfonlayer}{layer2}
        \begin{scope}[canvas is xy plane at z=1]
            \draw[line join=round, thick, fill=black!40, thin] (0.9,1) rectangle ++(-0.1,-2);
            %                          \draw[dashed] (0.875,-1) -- ++(0,2);
        \end{scope}
    \end{pgfonlayer}
    \begin{scope}[canvas is xz plane at y=1]
        \draw[line join=round, thick, fill=black!40, thin] (1,1) rectangle ++(-0.1,-2);
        \draw[dashed, black!40, thick] (0.9,-1) -- ++(0,2);
    \end{scope}
    \begin{pgfonlayer}{layer2}
        \begin{scope}[canvas is xz plane at y=1]
            \draw[line join=round, thick, fill=black!40, thin] (0.9,1) rectangle ++(-0.1,-2);
        \end{scope}
    \end{pgfonlayer}
\end{tikzpicture}

\end{document}

[1]:https://i.stack.imgur.com/aRuca.png

答案1

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{3d}
\begin{document}
\begin{tikzpicture}
\begin{scope}[canvas is xy plane at z=1]
  \draw[line join=round, thick, fill=black!40] (1,1) rectangle ++(-0.25,-2);
  \draw[dashed] (0.875,-1) -- ++(0,2);
\end{scope}
\begin{scope}[canvas is xz plane at y=1]
  \draw[line join=round, thick, fill=black!40] (1,1) rectangle ++(-0.25,-2);
  \draw[dashed] (0.875,-1) -- ++(0,2);
\end{scope}
  \begin{scope}[canvas is yz plane at x=0.875]
  \draw[line join=round, thick, fill=red!50,opacity=0.5] (-1.5,-1.5) rectangle (1.5,1.5);
\end{scope}
\begin{scope}[canvas is yz plane at x=1]
  \draw[line join=round, thick, fill=black!20] (-1,-1) rectangle (1,1);
\end{scope}   
\begin{scope}[canvas is xy plane at z=1]
  \clip (1,2) rectangle ++(-0.125,-4);
  \draw[line join=round, thick, fill=black!40] (1,1) rectangle ++(-0.25,-2);
  \draw[dashed] (0.875,-1) -- ++(0,2);
\end{scope}
\begin{scope}[canvas is xz plane at y=1]
  \clip (1,2) rectangle ++(-0.125,-4);
  \draw[line join=round, thick, fill=black!40] (1,1) rectangle ++(-0.25,-2);
  \draw[dashed] (0.875,-1) -- ++(0,2);
\end{scope}
\draw (1,0,0) -- (2,0,0);
\end{tikzpicture}
\end{document}

编辑:在我看来,这个图并没有因为3d库而变得更好——这里只是带有 3D 坐标:

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}[line join=round, thick]
\draw[fill=black!40] (-0.125,-1,1) -- (-0.125,1,1) -- (0.125,1,1) -- (0.125,-1,1) -- cycle;
\draw[fill=black!40]  (-0.125,1,-1) -- (-0.125,1,1) -- (0.125,1,1) -- (0.125,1,-1) -- cycle;
\draw[dashed, thin] (0,1,-1) -- (0,1,1) (0,-1,1) -- (0,1,1);
\draw[fill=red!50, fill opacity=0.5]  (0,-1.5,-1.5) -- (0,1.5,-1.5) -- (0,1.5,1.5) -- (0,-1.5,1.5) -- cycle;
\draw[fill=black!20]  (0.125,-1,-1) --(0.125,-1,1) -- (0.125,1,1) -- (0.125,1,-1)  -- cycle;
\clip(0,-2,-2) -- (0,-2,1) -- (0,1,1) -- (0,1,-2) -- cycle;
\draw[fill=black!40] (-0.125,-1,1) -- (-0.125,1,1) -- (0.125,1,1) -- (0.125,-1,1) -- cycle;
\draw[fill=black!40]  (-0.125,1,-1) -- (-0.125,1,1) -- (0.125,1,1) -- (0.125,1,-1) -- cycle;
\draw[dashed, thin] (0,1,-1) -- (0,1,1) (0,-1,1) -- (0,1,1);
\end{tikzpicture}
\end{document}

fill opacity红色平面的 改为 ,使opacity外围变成纯黑色,而不是透明灰色。

盒子被红色飞机切成两半

放大框角: 放大框角

相关内容