答案1
使用渐近线来绘制这些东西很简单。
\documentclass[border=2pt]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=AsyTest}
import graph3;
import solids;
size(8cm,6cm);
settings.render = 4;
currentprojection=orthographic(30,100,25);
material greensphere=material( grey+green, yellow, black, green);
material bluesphere=material( grey+blue, yellow, black, blue);
material m_eyeB=material(diffusepen=gray(0.001), emissivepen=gray(0.01), specularpen=gray(0.9),shininess=0.15);
for (int i=1; i <4; i+=1)
{
for (int j=1; j <4; j+=1)
{
for (int k=1; k <4; k+=1)
{
draw(surface(sphere(i*X+j*Y+k*Z,0.2)),surfacepen=greensphere);
}
draw(i*X+j*Y -- i*X+j*Y+3Z,gray);
draw(i*X+j*Z -- i*X+j*Z+3Y,gray);
draw(i*Y+j*Z -- i*Y+j*Z+3X,gray);
}
}
for (int i=1; i <3; i+=1)
{
for (int j=1; j <3; j+=1)
{
for (int k=1; k <3; k+=1)
{
draw(surface(sphere(0.5*(X+Y+Z)+i*X+j*Y+k*Z,0.3)),surfacepen=bluesphere);
}
}
}
draw(3X-2Y -- 4X-2Y,Arrow3, L=Label("$x_1$",position=EndPoint));
draw(3X-2Y -- 3X-Y,Arrow3, L=Label("$x_2$", position=EndPoint));
draw(3X-2Y -- 3X-2Y+Z,Arrow3, L=Label("$x_3$", position=EndPoint));
\end{asypicture}
\end{document}
也可以用 Ti 绘制钾Z,但是它没有 3D 引擎,所以必须确保按照“正确”的顺序绘制对象。
\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
% lattice
\foreach \X in {1,...,4}
{
\foreach \Y in {1,...,4}
{
\draw[gray] (-\X,-\Y,-1) -- (-\X,-\Y,-4);
\draw[gray] (-\X,-1,-\Y) -- (-\X,-4,-\Y);
\draw[gray] (-1,-\X,-\Y) -- (-4,-\X,-\Y);
}
}
% blue balls
\foreach \X in {1,2}
{
\foreach \Y in {1,2}
{
\foreach \Z in {1,2}
{
\shade[ball color=blue] (-\X-0.5,-\Y-0.5,-\Z-0.5) circle (3.5mm);
}
}
}
% green balls
\foreach \X in {1,...,3}
{
\foreach \Y in {1,...,3}
{
\foreach \Z in {1,...,3}
{
\shade[ball color=green] (-\X,-\Y,-\Z) circle (2mm);
}
}
}
\end{tikzpicture}
\end{document}
请注意,这幅图还不是完美的,你必须一个接一个地画出绿球和蓝球。还要注意,tikz-3dplot
你可以更轻松地旋转视图等等,但必须手动调整的基本问题仍然存在。