mate2code

Bilinski dodecahedron

Sep 27th, 2019
677
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // https://commons.wikimedia.org/wiki/Category:Bilinski_dodecahedron_(gray)
  2.  
  3. // for i in $(seq 0 7); do povray bilinski.pov +ua +fn +H2000 +W2000 -D -k$i -O$i; done
  4.  
  5. #version 3.6;
  6. global_settings { assumed_gamma 1.0 }
  7. #default{ finish{ ambient 0.1 diffuse 0.9 conserve_energy } }
  8.  
  9. #include "colors.inc"
  10. #include "math.inc"
  11. #include "RotateDirOnDir.inc"
  12.  
  13.  
  14. ///////////////////////////// values
  15.  
  16. #declare RadVert = .15;
  17. #declare RadEdge = .045;
  18.  
  19. #declare Factor = 1.5;
  20. #declare Phi = (1 + sqrt(5)) / 2;
  21. #declare C0 = Factor;
  22. #declare C1 = Factor * Phi;
  23. #declare C2 = Factor * Phi * Phi;
  24. #declare C3 = Factor * Phi * Phi * Phi;
  25.  
  26.  
  27. ///////////////////////////// points and arrays of points
  28.  
  29. #declare P = array[16]{  // The last two entries are the inner points.
  30.     <0, -C2, 0>, <0, C2, 0>,
  31.     <0, -C0, -C0>, <0, -C0, C0>, <0, C0, -C0>, <0, C0, C0>,
  32.     <-C1, -C1, 0>, <C1, -C1, 0>, <-C1,  C1, 0>, <C1,  C1, 0>,
  33.     <-C1, 0, -C0>, <-C1, 0, C0>, <C1, 0, -C0>, <C1, 0, C0>,
  34.     <0, -2*C1 + C2, 0>, <0, 2*C1 - C2, 0>
  35. }
  36.  
  37. #declare EdgeArrays = array[24]{
  38.     array[2]{0,2}, array[2]{0,3}, array[2]{4,1}, array[2]{5,1},
  39.  
  40.     array[2]{0,6}, array[2]{0,7}, array[2]{8,1}, array[2]{9,1},
  41.  
  42.     array[2]{2,10}, array[2]{2,12}, array[2]{3,11}, array[2]{3,13},
  43.     array[2]{10,4}, array[2]{12,4}, array[2]{11,5}, array[2]{13,5},
  44.  
  45.     array[2]{6,10}, array[2]{6,11}, array[2]{7,12}, array[2]{7,13},
  46.     array[2]{10,8}, array[2]{11,8}, array[2]{12,9}, array[2]{13,9}
  47. }
  48. #declare InnerEdgeArrays = array[8]{
  49.     array[2]{6,14}, array[2]{7,14}, array[2]{15,8}, array[2]{15,9},
  50.     array[2]{2,15}, array[2]{3,15}, array[2]{14,4}, array[2]{14,5}
  51. }
  52.  
  53. #declare FaceArrays = array[12]{
  54.     array[5]{0,2,10,6,0}, array[5]{0,2,12,7,0}, array[5]{0,3,11,6,0}, array[5]{0,3,13,7,0},
  55.     array[5]{1,4,10,8,1}, array[5]{1,4,12,9,1}, array[5]{1,5,11,8,1}, array[5]{1,5,13,9,1},
  56.  
  57.     array[5]{2,10,4,12,2},
  58.     array[5]{3,11,5,13,3},
  59.  
  60.     array[5]{6,10,8,11,6},
  61.     array[5]{7,12,9,13,7}
  62. }
  63.  
  64. #declare BlackVerticesArray = array[2]{ P[0], P[1] }
  65. #declare RedVerticesArray = array[4]{ P[2], P[3], P[4], P[5] }
  66. #declare GreenVerticesArray = array[4]{ P[6], P[7], P[8], P[9] }
  67. #declare BlueVerticesArray = array[4]{ P[10], P[11], P[12], P[13] }
  68. #declare InnerVerticesArray = array[2]{ P[14], P[15] }
  69.  
  70.  
  71. ///////////////////////////// parameters
  72.  
  73. #declare ShowInner = false;
  74.  
  75. #declare OrthoCameraLocation = 50 * vnormalize(<0, 0, -1>);
  76. #declare PerspCameraLocation = 50 * vnormalize(<13.2, 3, -45>);
  77.  
  78.  
  79. #if (clock=0)
  80.     #declare Ortho = false;
  81. #end
  82.  
  83. #if (clock=1)
  84.     #declare ViewSolidFrom = <45, 0, 0>;  // side
  85.     #declare Ortho = true;
  86. #end
  87. #if (clock=2)
  88.     #declare ViewSolidFrom = <0, 0, -45>;  // front
  89.     #declare Ortho = true;
  90. #end
  91. #if (clock=3)
  92.     #declare ViewSolidFrom = <0, 45, 0>;  // top
  93.     #declare Ortho = true;
  94. #end
  95.  
  96. #if (clock=4)
  97.     #declare ViewSolidFrom = <0, -C2, -C1>;
  98.     #declare Ortho = true;
  99. #end
  100. #if (clock=5)
  101.     #declare ViewSolidFrom = <C3, -C2, 0>;  // 1 behind 9
  102.     #declare Ortho = true;
  103. #end
  104. #if (clock=6)
  105.     #declare ViewSolidFrom = <C1, 0, -(C1-C0)>;
  106.     #declare Ortho = true;
  107. #end
  108. #if (clock=7)
  109.     #declare ViewSolidFrom = <C1, -C2, -C0>;
  110.     #declare Ortho = true;
  111. #end
  112.  
  113.  
  114. ///////////////////////////// camera and light
  115.  
  116. camera{
  117.     #if (Ortho)
  118.         orthographic
  119.         location OrthoCameraLocation
  120.         look_at  <0, 0, 0>
  121.     #else
  122.         location PerspCameraLocation
  123.         look_at  <0, .022, 0>
  124.     #end
  125.  
  126.     right    x*image_width/image_height
  127.     angle    9.5
  128. }
  129.  
  130. light_source{ <-400, 500, -300> color White*0.9 shadowless}
  131. light_source{ <400, 200, 100> color White*0.4 shadowless}
  132. light_source{ PerspCameraLocation  color rgb<0.9,0.9,1>*0.2 shadowless}
  133. sky_sphere{ pigment{ White } }
  134.  
  135.  
  136. ///////////////////////////// define elements
  137.  
  138. #declare BlackVertices = union {  // top and bottom
  139.     #for( Index, 0, 1 )
  140.         sphere{ BlackVerticesArray[Index], RadVert }
  141.     #end
  142.     pigment{ color rgb .1 }
  143. }
  144. #declare RedVertices = union {  // x
  145.     #for( Index, 0, 3 )
  146.         sphere{ RedVerticesArray[Index], RadVert }
  147.     #end
  148.     pigment{ color Red }
  149. }
  150. #declare GreenVertices = union {  // right-hand y (left-hand z)
  151.     #for( Index, 0, 3 )
  152.         sphere{ GreenVerticesArray[Index], RadVert }
  153.     #end
  154.     pigment{ color rgb<0, .5, 0> }
  155. }
  156. #declare BlueVertices = union {  // right-hand z (left-hand y)
  157.     #for( Index, 0, 3 )
  158.         sphere{ BlueVerticesArray[Index], RadVert }
  159.     #end
  160.     pigment{ color rgb<.03, .03, 1> }
  161. }
  162. #declare InnerVertices = union {
  163.     #for( Index, 0, 1 )
  164.         sphere{ InnerVerticesArray[Index], RadVert }
  165.     #end
  166.     pigment{ color Orange }
  167. }
  168.  
  169. #declare Edges = union {
  170.     #for( Index, 0, 23 )
  171.         #local EdgeArray = EdgeArrays[Index];
  172.         cylinder{ P[EdgeArray[0]], P[EdgeArray[1]], RadEdge }
  173.     #end
  174.     pigment{ color rgb .5 }
  175. }
  176. #declare InnerEdges = union {
  177.     #for( Index, 0, 7 )
  178.         #local EdgeArray = InnerEdgeArrays[Index];
  179.         cylinder{ P[EdgeArray[0]], P[EdgeArray[1]], RadEdge * 3/4 }
  180.     #end
  181.     pigment{ color rgb .9 }
  182. }
  183.  
  184. #declare Faces = union {
  185.     #for( Index, 0, 11 )
  186.         #local FaceArray = FaceArrays[Index];
  187.         polygon{ 4,
  188.             #for(VertexIndexInFace, 0, 3)
  189.                 P[FaceArray[VertexIndexInFace]]
  190.             #end
  191.         }
  192.     #end
  193.     pigment{color rgbt<1, 1, 1, .5>}
  194. }
  195.  
  196.  
  197. ///////////////////////////// show
  198.  
  199. union{
  200.     object{BlackVertices}
  201.     object{RedVertices}
  202.     object{BlueVertices}
  203.     object{GreenVertices}
  204.  
  205.     object{Edges}
  206.     object{Faces}
  207.  
  208.     #if (ShowInner)
  209.         object{InnerVertices}
  210.         object{InnerEdges}
  211.     #end
  212.  
  213.     #if (Ortho)
  214.         RotateDirOnDir(ViewSolidFrom, OrthoCameraLocation)
  215.     #end
  216. }
RAW Paste Data