带有虚线和填充面的 3D 立方体

带有虚线和填充面的 3D 立方体

我试图绘制一个类似于图中的立方体,但没有得到预期的结果。在此处输入图片描述

\documentclass[letterpaper, 12pt]{article}
\usepackage[margin = 1in]{geometry}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}

\draw[dashed] (2,0,0) -- (2,2,0) node[midway,right] {$L$};

\draw [dashed] (0,2,2) -- (0,0,2);

\draw[dashed] (0,0,0) -- (0,2,0);
\draw [dashed] (2,0,2) -- (2,2,2);

\draw[very thick] (0,2,0) -- (0,2,2) -- (2,2,2) -- (2,2,0) -- cycle;
\filldraw[color=gray!40] (0,2,0) -- (0,2,2) -- (2,2,2) -- (2,2,0) -- cycle;

\draw[very thick] (0,0,0) -- (0,0,2) -- (2,0,2) -- (2,0,0) -- cycle;
\filldraw[color=gray!40] (0,0,0) -- (0,0,2) -- (2,0,2) -- (2,0,0) -- cycle;

\end{tikzpicture}
\end{document}

答案1

在您的构造中,通过填充后绘制虚线,我们得到了与您想要的图形相似的图形。

截屏

\documentclass[letterpaper, 12pt]{article}
\usepackage[margin = 1in]{geometry}
\usepackage[spanish]{babel}
%\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usetikzlibrary{positioning}
%\usepackage{pgfplots}
%\pgfplotsset{compat=1.15}

\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}


\draw[very thick] (0,2,0) -- (0,2,2) -- (2,2,2) -- (2,2,0) -- cycle;
\filldraw[color=gray!40] (0,2,0) -- (0,2,2) -- (2,2,2) -- (2,2,0) -- cycle;

\draw[very thick] (0,0,0) -- (0,0,2) -- (2,0,2) -- (2,0,0) -- cycle;
\filldraw[color=gray!40] (0,0,0) -- (0,0,2) -- (2,0,2) -- (2,0,0) -- cycle;


\draw[dashed] (2,0,0) -- (2,2,0) node[midway,right] {$L$};

\draw [dashed] (0,2,2) -- (0,0,2);

\draw[dashed] (0,0,0) -- (0,2,0);
\draw [dashed] (2,0,2) -- (2,2,2);
\end{tikzpicture}
\end{document}

答案2

像这样?

\documentclass[letterpaper, 12pt]{article}
\usepackage[margin = 1in]{geometry}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{xcolor}

\pgfmathsetmacro{\a}{7} %  
\pgfmathsetmacro{\b}{4} % 
\pgfmathsetmacro{\teta}{125}
\begin{document}
\begin{tikzpicture}[
x={(1cm,0cm)},
y={({cos(\teta)*1cm}, {sin(\teta)*1cm})},
z={(0cm,1cm)},
]
\coordinate (A) at (0,0,0); 
\coordinate (B) at (\a,0,0); 
\coordinate (C) at (\a,\b,0); 
\coordinate (D) at (0,\b,0); 
\begin{scope}[shift={(\b,\a)}]
\coordinate (E) at (0,0,0); 
\coordinate (F) at (\a,0,0); 
\coordinate (G) at (\a,\b,0); 
\coordinate (H) at (0,\b,0);
\end{scope}
\draw[ultra thick,fill=pink] (A) -- (B)  -- (C) -- (D) --cycle;
\draw[ultra thick,fill=pink] (E) -- (F)  -- (G) -- (H) --cycle;
\path (B)--(D)node[midway]{\huge $i$};
\path (F)--(H)node[midway]{\huge $j$};
\draw [ultra thick, dashed](A)--(B)node[midway,below]{\huge $X$};
\draw [ultra thick, dashed](A)--(D)node[midway,left=2mm]{\huge $Y$};
\draw [ultra thick, dashed](D)--(H)node[midway,left]{\huge $L$};
\draw [ultra thick, dashed](A)--(E) (B)--(F) (C)--(G);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容