Monday, 26 March 2012

pr.probability - How to fill a simplex with almost disjoint cuboids?

OK, since we finally have figured out what Andres is asking and since 600 characters is a bit too restrictive, I'll post this as an answer.



The following Asymptote code will draw the filling except I used the size 4 simplex instead of size 1 one here:




size(400);
import three;
import graph3;


pen[] q={red,green,magenta,blue,black};
q.cyclic(true);

int N=4;
triple O=(0,0,0),A=(4,0,0),B=(0,4,0),C=(0,0,4);
draw(O--A--B--C--A--C--O--B);
for(int n=0;N>n;++n)

{
real s=1/2^n;
for(real x=4-3*s;x>=0;x-=2s)
for(real y=4-x-3*s;y>=0;y-=2s)
{
draw(shift((x,y,4-x-y-3*s))*scale3(s)*unitcube,q[n]);
draw(shift((x-s,y,4-x-y-3*s))*scale3(s)*unitcube,q[n]);
draw(shift((x-s,y+s,4-x-y-3*s))*scale3(s)*unitcube,q[n]);
draw(shift((x-s,y,4-x-y-2*s))*scale3(s)*unitcube,q[n]);
}
}


The unitcube is just $[0,1]^3$, the rest should be self-explanatory.

No comments:

Post a Comment