3

I used the following code from another tikz question to create a 3D lattice

\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=3dgrid}
settings.render=8;
settings.outformat='png';
size(200);
import graph3;

int L=4; triple s; currentprojection=perspective(27,19,11); real r = 0.1; surface site = scale3(r)*unitsphere; real dist = 1.5;

for(int i=1;i<=L;++i) { for(int j=1;j<=L;++j) { for(int k=1;k<=L;++k) { s=dist(i,j,k); draw(shift(s)site,red); if (i < L) draw(shift(s) * (O -- (dist-r)X), p=blue+0.7pt); if (j < L) draw(shift(s) (O -- (dist-r)Y), p=gray+0.7pt); if (k < L) draw(shift(s) (O -- (dist-r)*Z), p=green+0.7pt); } } } \end{asypicture} \end{document}

enter image description here

But I also want to fill in colors inside the cubes in a checkerboard pattern. Is there an easy way to do that?

Edit: I realize I can use the draw(unitcube,blue)) but can one extend this to cuboids?

user25957
  • 623
  • I realize I can use the draw(unitcube,blue)) but can one extend this to cuboids? – user25957 Mar 19 '22 at 23:52
  • It's a good idea to link the "other tikz question" to give proper credit to the original author of the code. – Sandy G Mar 20 '22 at 15:54
  • 1
    @user25957 maybe draw(shift(A)xscale(r)yscale(s)unitcube,blue)). Moreover, I am not sure I understand about this " inside the cubes in a checkerboard pattern*" – Black Mild Mar 21 '22 at 04:57
  • "inside the cubes in a checkerboard pattern" means color alternates --let one cube be black, then all of the neighbors that share a face with it are white and vice-versa. – user25957 Mar 21 '22 at 06:32
  • @user25957 Oh, I got what you want to draw. It is not difficult in programming with Asymptote. I am a bit curious in which context that kind of figure arises – Black Mild Mar 24 '22 at 09:17

0 Answers0