mate2code

Myers-Briggs tesseract cubes

Mar 11th, 2019
630
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // source for the four files like
  2. // https://commons.wikimedia.org/wiki/File:Myers-Briggs_tesseract_FT.png
  3. // in
  4. // https://commons.wikimedia.org/wiki/Category:Myers-Briggs_tesseract
  5.  
  6. // console command:
  7. // for i in `seq 0 3`; do povray tesseract_cubes_mb.pov +ua +fn +H4000 +W4400 -D -k$i -Omb_cubes_$i; done
  8.  
  9. #version 3.6;
  10. global_settings { assumed_gamma 1.0 }
  11. #default{ finish{ ambient 0.1 diffuse 0.9 conserve_energy}}
  12.  
  13. #include "colors.inc"
  14.  
  15.  
  16. ////////////////////////////////////////////////////////////////////////
  17.  
  18. #declare Camera_Position = <4, 7, -30>;
  19. camera{
  20.     location Camera_Position
  21.     right    x*image_width/image_height
  22.     angle    12.5
  23.     look_at  <-.19, -.2, 0>
  24. }
  25.  
  26.  
  27. light_source{ <-400, 500, -300> color White*0.9 shadowless}
  28. light_source{ <400, 200, 100> color White*0.4 shadowless}
  29. light_source{ Camera_Position  color rgb<0.9,0.9,1>*0.2 shadowless}
  30. sky_sphere{ pigment{ White } }
  31.  
  32.  
  33. ////////////////////////////////////////////////////////////////////////
  34.  
  35. #declare RadEdge = .01;
  36. #declare RadVert = .05;
  37. #declare RadScale = .6;
  38.  
  39. #declare Transparency = .8;
  40.  
  41. #declare VertexRankParities = array[16]{ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }
  42.  
  43. #declare Scale = .47;
  44. #declare P = array[16]{
  45.     <-1,-1,-1>, <-1,1,-1>, <-1,-1,1>, <-1,1,1>, <1,-1,-1>, <1,1,-1>, <1,-1,1>, <1,1,1>,
  46.     <-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
  47. };
  48.  
  49. #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} };
  50.  
  51. #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} };
  52.  
  53. #declare EdgesByCube = array[8]{ array[12]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, array[12]{0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19}, array[12]{0, 4, 5, 6, 12, 13, 14, 20, 21, 22, 23, 24}, array[12]{1, 4, 7, 8, 12, 15, 16, 20, 21, 25, 26, 27}, array[12]{2, 5, 9, 10, 13, 17, 18, 22, 23, 28, 29, 30}, array[12]{3, 7, 9, 11, 15, 17, 19, 25, 26, 28, 29, 31}, array[12]{6, 8, 10, 11, 20, 22, 24, 25, 27, 28, 30, 31}, array[12]{14, 16, 18, 19, 21, 23, 24, 26, 27, 29, 30, 31} }
  54.  
  55. #declare FacesByCube = array[8]{ array[6]{0, 1, 2, 3, 4, 5}, array[6]{0, 6, 7, 8, 9, 10}, array[6]{1, 6, 11, 12, 13, 14}, array[6]{2, 7, 11, 15, 16, 17}, array[6]{3, 8, 12, 18, 19, 20}, array[6]{4, 9, 15, 18, 21, 22}, array[6]{5, 13, 16, 19, 21, 23}, array[6]{10, 14, 17, 20, 22, 23} }
  56.  
  57. #declare Arial = "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf";
  58. #declare Text = array[16]{ "ESFJ", "ESFP", "ENFJ", "ENFP","ESTJ", "ESTP", "ENTJ", "ENTP", "ISFJ", "ISFP", "INFJ", "INFP","ISTJ", "ISTP", "INTJ", "INTP" };
  59. #declare FirstCubeIndex = clock;
  60. #declare CubeLabels = array[8]{"E", "F", "S", "J", "P", "N", "T", "I"};
  61. #declare Dist = .72;  // transform distance
  62. #declare CubeLabelTransforms = array[8]{<0,-1.26,0>, <-Dist,0,0>, <0,-.016,-.95>, <.02,-Dist-.08,0>, <.05,Dist+.08,0>, <-.07,-.04,.95>, <Dist,0,0>, <.11,0,0>}
  63.  
  64. ////////////////////////////////////////////////////////////////////////
  65.  
  66. union{
  67.  
  68.     // VERTICES
  69.     union{
  70.         #for( Index, 0, 15 )
  71.             #if(Index<8)   #local R = RadVert;   #else   #local R = RadVert*RadScale;   #end
  72.             sphere{
  73.                 P[Index], R
  74.                 #if(VertexRankParities[Index])
  75.                     pigment{color rgb<1,0.8,0.65>*.2}
  76.                 #else
  77.                     pigment{color rgb<1,0.8,0.65>*.5}
  78.                 #end
  79.             }
  80.         #end
  81.     }
  82.  
  83.     // ALL EDGES (LIGHT)
  84.     union{
  85.         #for( Index, 0, 31 )
  86.             #local EdgeArray = Edges[Index];
  87.             #local A = EdgeArray[0];
  88.             #local B = EdgeArray[1];
  89.             #if(A<8)   #local RadA = RadEdge;   #else   #local RadA = RadEdge*RadScale;   #end
  90.             #if(B<8)   #local RadB = RadEdge;   #else   #local RadB = RadEdge*RadScale;   #end
  91.             cone{ P[A], RadA, P[B], RadB }
  92.         #end
  93.         pigment{color rgbt <.5, .5, .5, Transparency>}
  94.     }
  95.  
  96.     // EDGES, FACES AND LABELS FOR THE TWO CUBES
  97.     #for(CubeIndexIndex, 0, 1)
  98.        
  99.         #if(CubeIndexIndex)
  100.             #declare CubeIndex = FirstCubeIndex;
  101.         #else
  102.             #declare CubeIndex = 7 - FirstCubeIndex;
  103.         #end
  104.  
  105.         #declare EdgesForCube = EdgesByCube[CubeIndex];
  106.         #declare FacesForCube = FacesByCube[CubeIndex];
  107.  
  108.         // CUBE EDGES
  109.         union{
  110.             #for( Index, 0, 11 )
  111.                 #local EdgeArray = Edges[EdgesForCube[Index]];
  112.                 #local A = EdgeArray[0];
  113.                 #local B = EdgeArray[1];
  114.                 #if(A<8)   #local RadA = RadEdge+.0001;   #else   #local RadA = RadEdge*RadScale+.0001;   #end
  115.                 #if(B<8)   #local RadB = RadEdge+.0001;   #else   #local RadB = RadEdge*RadScale+.0001;   #end
  116.                 cone{ P[A], RadA, P[B], RadB }
  117.             #end
  118.             pigment{color rgb .5}
  119.         }
  120.  
  121.         // CUBE FACES
  122.         union{
  123.             #for( Index, 0, 5 )
  124.                 #local FaceArray = Faces[FacesForCube[Index]];
  125.                 polygon{ 5, P[FaceArray[0]], P[FaceArray[1]], P[FaceArray[3]], P[FaceArray[2]], P[FaceArray[0]] }
  126.             #end
  127.             pigment{color rgbt<0, 0, 1, .8>}
  128.         }
  129.  
  130.         // CUBE LABELS
  131.         text { ttf Arial,  CubeLabels[CubeIndex],  .03,  0
  132.             scale .5
  133.             translate CubeLabelTransforms[CubeIndex]
  134.             translate -.142*x -.18*y
  135.         }
  136.  
  137.     #end
  138.  
  139.     // VERTEX LABELS
  140.     #for( Index, 0, 15 )
  141.         text { ttf Arial,  Text[Index],  .03,  0
  142.  
  143.             #if(Index<8)   scale .1   #else   scale .075   #end    // labels for the inner cube are smaller
  144.  
  145.             translate P[Index]   // move label from center to vertex
  146.  
  147.             #if(Index<8)  // OUTSIDE
  148.  
  149.                 #if(mod(div(Index,4),2))  // RIGHT
  150.                     translate .2*x
  151.                 #else                     // LEFT
  152.                     translate -.2*x
  153.                 #end
  154.  
  155.                 #if(mod(Index, 2))  // TOP
  156.                     translate .065*y
  157.                 #else               // BOTTOM
  158.                     translate -.065*y
  159.                 #end
  160.  
  161.                 translate <-.12, -.035, 0>
  162.  
  163.             #else         // INSIDE
  164.  
  165.                 #if(mod(div(Index,4),2))  // RIGHT
  166.                     translate -.135*x
  167.                 #else                     // LEFT
  168.                     translate .135*x
  169.                 #end
  170.  
  171.                 #if(mod(Index, 2))  // TOP
  172.                     translate -.06*y
  173.                 #else               // BOTTOM
  174.                     translate .06*y
  175.                 #end
  176.  
  177.                 translate <-.072, -.029, 0>
  178.  
  179.             #end
  180.  
  181.         }
  182.     #end
  183.  
  184.     scale 2.25
  185.  
  186. }
RAW Paste Data