立方体内的角立方体

立方体内的角立方体

我想使用 tikz 在立方体内绘制一个立方体,以便内部立方体是一个内角,就像下面的图画一样。 在此处输入图片描述 我希望内部立方体有阴影,并且其大小可以调整,但通常较小。此外,我希望留出空间来标记所有轴,这是一张概念图,因此不需要刻度线。

答案1

来自解决方案

\documentclass[border=5mm,tikz]{article}
\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}

\usepackage{xcolor}
\begin{document}
\newcommand{\Depth}{2}
\newcommand{\Height}{2}
\newcommand{\Width}{2}

\newcommand{\ccube}[5]{
\coordinate (O) at (#1);
\coordinate (A) at (0,#2,0);
\coordinate (B) at (0,#2,#3);
\coordinate (C) at (0,0,#3);
\coordinate (D) at (#4,0,0);
\coordinate (E) at (#4,#2,0);
\coordinate (F) at (#4,#2,#3);
\coordinate (G) at (#4,0,#3);

\draw[blue,fill=yellow!30,opacity=#5] (O) -- (C.center) -- (G) -- (D) -- cycle;% Bottom Face
\draw[blue,fill=blue!30,opacity=#5] (O) -- (A) -- (E) -- (D) -- cycle;% Back Face
\draw[blue,fill=red!10,opacity=#5] (O) -- (A) -- (B) -- (C) -- cycle;% Left Face
\draw[blue,fill=red!20,opacity=#5] (D) -- (E) -- (F) -- (G) -- cycle;% Right Face
\draw[blue,fill=red!20,opacity=#5] (C) -- (B) -- (F) -- (G) -- cycle;% Front Face
\draw[blue,fill=red!20,opacity=#5] (A) -- (B) -- (F) -- (E) -- cycle;% Top Face}
}

\begin{tikzpicture}

\coordinate(O) at (0,0,0);

\ccube{O}{2}{2}{-2}{0.8}
\ccube{O}{5}{5}{-5}{0.2}

\draw ($(C) +(0,-0.5)$) -- node[below,sloped]{label 1} ($(O)+(0,-0.5)$);
\draw ($(C) +(0,-0.5)$) -- node[below,sloped]{label 2} ($(G)+(0,-0.5)$);
\draw ($(A) +(0.5,0)$) -- node[sloped,above]{label 3} ($(O)+(0.5,0)$);
%% Following is for debugging purposes so you can see where the points are
%% These are last so that they show up on top
\foreach \xy in {O, A, B, C, D, E, F, G}{
    \node at (\xy) {\xy};
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

运行xelatex

\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\psset{lightsrc=viewpoint,viewpoint=50 60 25 rtp2xyz,Decran=50}
\begin{pspicture}[showgrid=false](-3,-3)(3,3)
\psSolid[object=cube,a=4,action=draw]
\psSolid[object=cube,a=1,fillcolor=yellow,action=draw**](-1.5,1.5,-1.5)
\end{pspicture}

\end{document}

在此处输入图片描述

相关内容