Advertisement
mate2code

Tesseract central projection

Mar 11th, 2019
2,684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // https://commons.wikimedia.org/wiki/File:Tesseract_Schlegel_numbered.png
  2. // height/width=20/19, e.g. +H4000 +W3800
  3.  
  4. #version 3.6;
  5. global_settings { assumed_gamma 1.0 }
  6. #default{ finish{ ambient 0.1 diffuse 0.9 conserve_energy}}
  7.  
  8. #include "colors.inc"
  9.  
  10.  
  11. ////////////////////////////////////////////////////////////////////////
  12.  
  13. #declare Camera_Position = <4, 7, -30>;
  14. camera{
  15.     location Camera_Position
  16.     right    x*image_width/image_height
  17.     angle    11
  18.     look_at  <-.15, -.2, 0>
  19. }
  20.  
  21.  
  22. light_source{ <-400, 500, -300> color White*0.9 shadowless}
  23. light_source{ <400, 200, 100> color White*0.4 shadowless}
  24. light_source{ Camera_Position  color rgb<0.9,0.9,1>*0.2 shadowless}
  25. sky_sphere{ pigment{ White } }
  26.  
  27.  
  28. ////////////////////////////////////////////////////////////////////////
  29.  
  30. #declare RadEdge = .01;
  31. #declare RadVert = .05;
  32. #declare RadScale = .6;
  33.  
  34. #declare VertexRankParities = array[16]{ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }
  35.  
  36. #declare Scale = .47;
  37. #declare P = array[16]{
  38.     <-1,-1,-1>, <-1,1,-1>, <-1,-1,1>, <-1,1,1>, <1,-1,-1>, <1,1,-1>, <1,-1,1>, <1,1,1>,
  39.     <-1,-1,-1>*Scale, <-1,1,-1>*Scale, <-1,-1,1>*Scale, <-1,1,1>*Scale, <1,-1,-1>*Scale, <1,1,-1>*Scale, <1,-1,1>*Scale, <1,1,1>*Scale
  40. };
  41.  
  42. #declare Edges = array[32]{ array[2]{0, 1}, array[2]{0, 2}, array[2]{1, 3}, array[2]{2, 3}, array[2]{0, 4}, array[2]{1, 5}, array[2]{4, 5}, array[2]{2, 6}, array[2]{4, 6}, array[2]{3, 7}, array[2]{5, 7}, array[2]{6, 7}, array[2]{0, 8}, array[2]{1, 9}, array[2]{8, 9}, array[2]{2, 10}, array[2]{8, 10}, array[2]{3, 11}, array[2]{9, 11}, array[2]{10, 11}, array[2]{4, 12}, array[2]{8, 12}, array[2]{5, 13}, array[2]{9, 13}, array[2]{12, 13}, array[2]{6, 14}, array[2]{10, 14}, array[2]{12, 14}, array[2]{7, 15}, array[2]{11, 15}, array[2]{13, 15}, array[2]{14, 15} };
  43.  
  44. #declare Faces = array[24]{ array[4]{0, 1, 2, 3}, array[4]{0, 1, 4, 5}, array[4]{0, 2, 4, 6}, array[4]{1, 3, 5, 7}, array[4]{2, 3, 6, 7}, array[4]{4, 5, 6, 7}, array[4]{0, 1, 8, 9}, array[4]{0, 2, 8, 10}, array[4]{1, 3, 9, 11}, array[4]{2, 3, 10, 11}, array[4]{8, 9, 10, 11}, array[4]{0, 4, 8, 12}, array[4]{1, 5, 9, 13}, array[4]{4, 5, 12, 13}, array[4]{8, 9, 12, 13}, array[4]{2, 6, 10, 14}, array[4]{4, 6, 12, 14}, array[4]{8, 10, 12, 14}, array[4]{3, 7, 11, 15}, array[4]{5, 7, 13, 15}, array[4]{9, 11, 13, 15}, array[4]{6, 7, 14, 15}, array[4]{10, 11, 14, 15}, array[4]{12, 13, 14, 15} };
  45.  
  46.  
  47. ////////////////////////////////////////////////////////////////////////
  48.  
  49. union{
  50.  
  51.     // VERTICES
  52.     union{
  53.         #for( Index, 0, 15 )
  54.             #if(Index<8)   #local R = RadVert;   #else   #local R = RadVert*RadScale;   #end
  55.             sphere{
  56.                 P[Index], R
  57.                 #if(VertexRankParities[Index])
  58.                     pigment{color rgb<1,0.8,0.65>*.2}
  59.                 #else
  60.                     pigment{color rgb<1,0.8,0.65>*.5}
  61.                 #end
  62.             }
  63.         #end
  64.     }
  65.  
  66.     // EDGES
  67.     union{
  68.         #for( Index, 0, 31 )
  69.             #local EdgeArray = Edges[Index];
  70.             #local A = EdgeArray[0];
  71.             #local B = EdgeArray[1];
  72.             #if(A<8)   #local RadA = RadEdge;   #else   #local RadA = RadEdge*RadScale;   #end
  73.             #if(B<8)   #local RadB = RadEdge;   #else   #local RadB = RadEdge*RadScale;   #end
  74.             cone{ P[A], RadA, P[B], RadB }
  75.         #end
  76.         pigment{color rgb .5}
  77.     }
  78.  
  79.     // FACES
  80.     union{
  81.         #for( Index, 0, 23 )
  82.             #local FaceArray = Faces[Index];
  83.             polygon{ 5, P[FaceArray[0]], P[FaceArray[1]], P[FaceArray[3]], P[FaceArray[2]], P[FaceArray[0]] }
  84.         #end
  85.         pigment{color rgbt<0, 0, 1, .8>}
  86.     }
  87.  
  88.     // VERTEX LABELS
  89.     #for( Index, 0, 15 )
  90.         text { ttf "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",  str(Index,2,0),  .03,  0
  91.  
  92.             #if(Index<8)   scale .11   #else   scale .085   #end    // labels for the inner cube are smaller
  93.  
  94.             translate P[Index]   // move label from center to vertex
  95.  
  96.             #if(Index<8)  // OUTSIDE
  97.  
  98.                 #if(mod(div(Index,4),2))  // RIGHT
  99.                     translate .1*x
  100.                 #else                     // LEFT
  101.                     translate -.1*x
  102.                 #end
  103.  
  104.                 #if(mod(Index, 2))  // TOP
  105.                     translate .068*y
  106.                 #else               // BOTTOM
  107.                     translate -.068*y
  108.                 #end
  109.  
  110.                 translate <-.063, -.035, 0>
  111.  
  112.             #else         // INSIDE
  113.  
  114.                 #if(mod(div(Index,4),2))  // RIGHT
  115.                     translate -.08*x
  116.                 #else                     // LEFT
  117.                     translate .08*x
  118.                 #end
  119.  
  120.                 #if(mod(Index, 2))  // TOP
  121.                     translate -.062*y
  122.                 #else               // BOTTOM
  123.                     translate .062*y
  124.                 #end
  125.  
  126.                 translate <-.05, -.032, 0>
  127.  
  128.             #end
  129.  
  130.         }
  131.     #end
  132.  
  133.     scale 2.25
  134.  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement