我正在尝试根据以下屏幕截图创建 tikz 图像:
我可以弄清楚如何绘制金字塔,但到目前为止,我还是无法绘制红色阴影区域。以下是我取得的最小进展:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
[x={(0.648577cm, -0.290453cm)},
y={(0.759883cm, 0.300370cm)},
z={(-0.043879cm, 0.908523cm)},
scale=2.000000,
back/.style={densely dotted, thin},
edge/.style={densely dotted, thin},
facet/.style={fill=blue!95!black,fill opacity=0.000000},
vertex/.style={inner sep=1pt,circle,draw=green!25!black,fill=green!75!black,thick,anchor=base}]
\coordinate (-0.75000, -0.75000, -0.75000) at (-0.75000, -0.75000, -0.75000);
\coordinate (0.75000, -0.75000, -0.75000) at (0.75000, -0.75000, -0.75000);
\coordinate (-0.75000, 0.75000, -0.75000) at (-0.75000, 0.75000, -0.75000);
\coordinate (0.75000, 0.75000, -0.75000) at (0.75000, 0.75000, -0.75000);
\coordinate (0.00000, 0.00000, 1.00000) at (0.00000, 0.00000, 1.00000);
\fill[facet] (0.00000, 0.00000, 1.00000) -- (-0.75000, -0.75000, -0.75000) -- (-0.75000, 0.75000, -0.75000) -- cycle {};
\fill[facet] (0.00000, 0.00000, 1.00000) -- (-0.75000, -0.75000, -0.75000) -- (0.75000, -0.75000, -0.75000) -- cycle {};
\fill[facet] (0.00000, 0.00000, 1.00000) -- (0.75000, -0.75000, -0.75000) -- (0.75000, 0.75000, -0.75000) -- cycle {};
\fill[facet] (0.00000, 0.00000, 1.00000) -- (-0.75000, 0.75000, -0.75000) -- (0.75000, 0.75000, -0.75000) -- cycle {};
\draw[edge] (-0.75000, -0.75000, -0.75000) -- (0.75000, -0.75000, -0.75000);
\draw[edge] (-0.75000, -0.75000, -0.75000) -- (-0.75000, 0.75000, -0.75000);
\draw[edge] (-0.75000, -0.75000, -0.75000) -- (0.00000, 0.00000, 1.00000);
\draw[edge] (0.75000, -0.75000, -0.75000) -- (0.75000, 0.75000, -0.75000);
\draw[edge] (0.75000, -0.75000, -0.75000) -- (0.00000, 0.00000, 1.00000);
\draw[edge] (-0.75000, 0.75000, -0.75000) -- (0.75000, 0.75000, -0.75000);
\draw[edge] (-0.75000, 0.75000, -0.75000) -- (0.00000, 0.00000, 1.00000);
\draw[edge] (0.75000, 0.75000, -0.75000) -- (0.00000, 0.00000, 1.00000);
\node[vertex] at (-0.75000, -0.75000, -0.75000) {};
\node[vertex] at (0.75000, -0.75000, -0.75000) {};
\node[vertex] at (-0.75000, 0.75000, -0.75000) {};
\node[vertex] at (0.75000, 0.75000, -0.75000) {};
\node[vertex] at (0.00000, 0.00000, 1.00000) {};
\end{tikzpicture}
\end{document}
答案1
使用渐近线创建类似的东西相当容易。
\documentclass{article}
\usepackage[inline]{asymptote}
\begin{document}
\thispagestyle{empty}
% from http://www.piprime.fr/files/asymptote/modules/polyhedron_js/index.html
\begin{asy}
import polyhedron_js;
import three;
currentprojection=perspective(6,6,-1);
// comment the following line for OpenGl
// settings.render=0;
settings.tex="pdflatex";
settings.outformat="pdf"; // for opacity
// uncomment these lines for the coordinate axes
// real r=1.5;
// draw(Label("$x$",1), O--r*X, Arrow3(HookHead3));
// draw(Label("$y$",1), O--r*Y, Arrow3(HookHead3));
// draw(Label("$z$",1), O--r*Z, Arrow3(HookHead3));
polyhedron pyramid;
real sq2=sqrt(2)/2; real sq4=sqrt(2)/4;
pyramid[0]=(-sq2,-sq2,0)--(-sq2,sq2,0)--(sq2,sq2,0)--(sq2,-sq2,0)--cycle;
pyramid[1]=(sq2,-sq2,0)--(sq2,sq2,0)--(0,0,1)--cycle;
pyramid[2]=(sq2,sq2,0)--(-sq2,sq2,0)--(0,0,1)--cycle;
pyramid[3]=(-sq2,sq2,0)--(-sq2,-sq2,0)--(0,0,1)--cycle;
pyramid[4]=(-sq2,-sq2,0)--(sq2,-sq2,0)--(0,0,1)--cycle;
size(10cm);
polyhedron[] parr={shift(0,0,-sq2/2)*rotate(0,Z)*pyramid};
filldraw(parr,new pen[]{0.9blue},op=1); //
// if(!is3D())
// shipout(bbox(3mm,darkblue+3bp+miterjoin,FillDraw(paleblue)));
// draw(shift(0,0,0.5)*scale3(1)*surface(unitcircle3),opacity(0.2));
real radius=1.8;
path3 p3=O--arc(O,radius,0,0,180,0)--cycle; // define a wedge
draw(shift(0sq2/2,0sq2/2,0)*rotate(45,X)*surface(p3), blue+opacity(0.2));
draw(shift(0sq2/2,0sq2/2,0)*rotate(-45,Y)*rotate(90,Z)*surface(p3), blue+opacity(0.2));
path3 p4=O--arc(O,radius,0,0,90,0)--cycle; // define a wedge
draw(shift(0sq2/2,0sq2/2,0)*rotate(90,Z)*rotate(90,X)*surface(p4), blue+opacity(0.2));
// draw(shift(0sq2/2,0sq2/2,0)*rotate(45,Z)*rotate(45,X+Y)*rotate(45,Z)*surface(p4), blue+opacity(0.2));
\end{asy}
\end{document}
您需要运行xelatex
,然后会有一个 .asy 文件,您需要用 处理它asy
,然后您需要运行xelatex
两次。这只是一个起点,我没有做太多努力,因为我不知道您是否考虑过asymptote
基于解决方案。