Advertisement
Hirwanto

asympt04

Jan 26th, 2015
4,823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \begin{asy}
  2. size(200);
  3. import palette;
  4. import three;
  5.  
  6. currentprojection=orthographic(1,1,1);
  7.  
  8. triple[] M={
  9.   (-1,-1,-1),(0,-1,-1),(1,-1,-1),(1,0,-1),
  10.   (1,1,-1),(0,1,-1),(-1,1,-1),(-1,0,-1),
  11.   (-1,-1,0),(1,-1,0),(1,1,0),(-1,1,0),
  12.   (-1,-1,1),(0,-1,1),(1,-1,1),(1,0,1),(1,1,1),(0,1,1),(-1,1,1),(-1,0,1)
  13. };
  14.  
  15. surface[] Squares={
  16.   surface((1,-1,-1)--(1,1,-1)--(1,1,1)--(1,-1,1)--cycle),
  17.   surface((-1,-1,-1)--(-1,1,-1)--(-1,1,1)--(-1,-1,1)--cycle),
  18.   surface((1,1,-1)--(-1,1,-1)--(-1,1,1)--(1,1,1)--cycle),
  19.   surface((1,-1,-1)--(-1,-1,-1)--(-1,-1,1)--(1,-1,1)--cycle),
  20.   surface((1,-1,1)--(1,1,1)--(-1,1,1)--(-1,-1,1)--cycle),
  21.   surface((1,-1,-1)--(1,1,-1)--(-1,1,-1)--(-1,-1,-1)--cycle),
  22. };
  23.  
  24. int[][] SquaresPoints={
  25.   {2,3,4,10,16,15,14,9},
  26.   {0,7,6,11,18,19,12,8},
  27.   {4,5,6,11,18,17,16,10},
  28.   {2,1,0,8,12,13,14,9},
  29.   {12,13,14,15,16,17,18,19},
  30.   {0,1,2,3,4,5,6,7}
  31. };
  32.  
  33. int[][] index={
  34.   {0,2,4},{0,1},{1,2,4},{2,3},{1,3,4},{0,1},{0,3,4},{2,3},
  35.   {4,5},{4,5},{4,5},{4,5},
  36.   {0,2,5},{0,1},{1,2,5},{2,3},{1,3,5},{0,1},{0,3,5},{2,3}
  37. };
  38.  
  39. int[] Sponge0=array(n=6,value=1);
  40.  
  41. int[] eraseFaces(int n, int[] Sponge0) {
  42.   int[] temp=copy(Sponge0);
  43.   for(int k : index[n]) {
  44.     temp[k]=0;
  45.   }
  46.   return temp;
  47. }
  48.  
  49. int[][] Sponge1=new int[20][];
  50. for(int n=0; n < 20; ++n) {
  51.   Sponge1[n]=eraseFaces(n,Sponge0);
  52. }
  53.  
  54. int[][] eraseFaces(int n, int[][] Sponge1) {
  55.   int[][] temp=copy(Sponge1);
  56.   for(int k : index[n])
  57.     for(int n1 : SquaresPoints[k])
  58.       temp[n1][k]=0;
  59.   return temp;
  60. }
  61.  
  62. int[][][] Sponge2=new int[20][][];
  63. for(int n=0; n < 20; ++n)
  64.   Sponge2[n]=eraseFaces(n,Sponge1);
  65.  
  66. int[][][] eraseFaces(int n, int[][][] Sponge2) {
  67.   int[][][] temp=copy(Sponge2);
  68.   for(int k : index[n])
  69.     for(int n2: SquaresPoints[k])
  70.       for(int n1: SquaresPoints[k])
  71.         temp[n2][n1][k]=0;
  72.   return temp;
  73. }
  74.  
  75. int[][][][] Sponge3=new int[20][][][];
  76. for(int n=0; n < 20; ++n)
  77.   Sponge3[n]=eraseFaces(n,Sponge2);
  78.  
  79. surface s3;
  80. real u=2/3;
  81. for(int n3=0; n3 < 20; ++n3) {
  82.   surface s2;
  83.   for(int n2=0; n2 < 20; ++n2) {
  84.     surface s1;
  85.     for(int n1=0; n1 < 20; ++n1) {
  86.       for(int k=0; k < 6; ++k){
  87.         transform3 T=scale3(u)*shift(M[n1])*scale3(0.5);
  88.         if(Sponge3[n3][n2][n1][k] > 0) {
  89.           s1.append(T*Squares[k]);
  90.         }
  91.       }
  92.     }
  93.     transform3 T=scale3(u)*shift(M[n2])*scale3(0.5);
  94.     s2.append(T*s1);
  95.   }
  96.   transform3 T=scale3(u)*shift(M[n3])*scale3(0.5);
  97.   s3.append(T*s2);
  98. }
  99. s3.colors(palette(s3.map(abs),Rainbow()));
  100. draw(s3);
  101.  
  102. \end{asy}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement