如何在 tikz 中绘制带有坐标系的立方体?

如何在 tikz 中绘制带有坐标系的立方体?

我想绘制一个带有坐标系和箭头的透视立方体,以定义连续力学中的柯西应力张量。它应该看起来像这样:

应力定义立方体

该示例是按等距绘制的。我宁愿按透视图绘制。

希望你们能帮助我。谢谢!

诚挚的,克里斯

答案1

perspective以下是使用和库可以实现的功能的示例3d。要更改视角,只需更改3d view键中的角度即可。

\documentclass{standalone}

\usepackage{tikz}
    \usetikzlibrary{perspective}
    \usetikzlibrary{3d}
    \usetikzlibrary{arrows.meta}
    
\begin{document}
    
    \begin{tikzpicture}[%
        3d view = {15}{15}
    ]
    
        \draw[-{Latex[scale = 0.7]}] (-4, -4, 0) -- (-3, -4, 0)
            node[below] {\footnotesize$x$};
        \draw[-{Latex[scale = 0.7]}] (-4, -4, 0) -- (-4, -3, 0)
            node[right] {\footnotesize$y$};
        \draw[-{Latex[scale = 0.7]}] (-4, -4, 0) -- (-4, -4, 1)
            node[above] {\footnotesize$z$};

        \begin{scope}[canvas is xz plane at y = -2]
        
            \draw[
                fill = lightgray
            ] (-2, -2) rectangle (2, 2);
            
            \draw[-Latex] (-1.75, 0) -- (1.75, 0)
                node[below left] {$\sigma_{xy}$};
            \draw[-Latex] (0, -1.75) -- (0, 1.75)
                node[below left] {$\sigma_{zy}$};
        
        \end{scope}     
    
        \draw[Latex-] (0, -2, 0) -- (0, -3.5, 0)
            node[left] {$\sigma_{yy}$};
    
        \begin{scope}[canvas is yz plane at x = 2]
    
            \draw[
                fill = lightgray
            ] (-2, -2) rectangle (2, 2);
            
            \draw[-Latex] (1.75, 0) -- (-1.75, 0)
                node[below right] {$\sigma_{yx}$};
            \draw[-Latex] (0, -1.75) -- (0, 1.75)
                node[below right] {$\sigma_{zx}$};
    
        \end{scope} 

        \draw[Latex-] (2, 0, 0) -- (3.5, 0, 0)
            node[right] {$\sigma_{xx}$};

        \begin{scope}[canvas is xy plane at z = 2]

            \draw[
                fill = lightgray
            ] (-2, -2) rectangle (2, 2);

            \draw[-Latex] (-1.75, 0) -- (1.75, 0)
                node[above]{$\sigma_{xz}$};
            \draw[-Latex] (0, 1.75) -- (0, -1.75)
                node[above left]{$\sigma_{yz}$};

        \end{scope} 

        \draw[Latex-] (0, 0, 2) -- (0, 0, 3.5)
            node[above] {$\sigma_{zz}$};

    \end{tikzpicture}
    
\end{document}

得出的结果是:

在此处输入图片描述

然后,您可以查看TikZ 文档以适应特定需要。

相关内容