Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // source of the 8 files in
- // https://commons.wikimedia.org/wiki/Category:Tesseract_Schlegel_shadow_with_alternating_vertex_colors;_faces
- // like
- // https://commons.wikimedia.org/wiki/File:Tesseract_square_14.png
- // console command:
- // for i in `seq 0 23`; do povray tesseract_squares.pov +ua +fn +H4000 +W3800 -D -k$i -Osquare_$i; done
- #version 3.6;
- global_settings { assumed_gamma 1.0 }
- #default{ finish{ ambient 0.1 diffuse 0.9 conserve_energy}}
- #include "colors.inc"
- ////////////////////////////////////////////////////////////////////////
- #declare Camera_Position = <4, 7, -30>;
- camera{
- location Camera_Position
- right x*image_width/image_height
- angle 11
- look_at <-.15, -.2, 0>
- }
- light_source{ <-400, 500, -300> color White*0.9 shadowless}
- light_source{ <400, 200, 100> color White*0.4 shadowless}
- light_source{ Camera_Position color rgb<0.9,0.9,1>*0.2 shadowless}
- sky_sphere{ pigment{ White } }
- ////////////////////////////////////////////////////////////////////////
- #macro is_in(Element, Array)
- #local Found = false;
- #for(Index, 0, dimension_size(Array,1)-1)
- #if(Array[Index] = Element)
- #local Found = true;
- #end
- #end
- Found
- #end
- ////////////////////////////////////////////////////////////////////////
- #declare RadEdge = .01;
- #declare RadVert = .05;
- #declare RadScale = .6;
- #declare Transparency = .8;
- #declare VertexRankParities = array[16]{ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }
- #declare Scale = .47;
- #declare P = array[16]{
- <-1,-1,-1>, <-1,1,-1>, <-1,-1,1>, <-1,1,1>, <1,-1,-1>, <1,1,-1>, <1,-1,1>, <1,1,1>,
- <-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
- };
- #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} };
- #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} };
- #declare VerticesBySquare = 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} }
- #declare EdgesBySquare = array[24]{ array[4]{0, 1, 2, 3}, array[4]{0, 4, 5, 6}, array[4]{1, 4, 7, 8}, array[4]{2, 5, 9, 10}, array[4]{3, 7, 9, 11}, array[4]{6, 8, 10, 11}, array[4]{0, 12, 13, 14}, array[4]{1, 12, 15, 16}, array[4]{2, 13, 17, 18}, array[4]{3, 15, 17, 19}, array[4]{14, 16, 18, 19}, array[4]{4, 12, 20, 21}, array[4]{5, 13, 22, 23}, array[4]{6, 20, 22, 24}, array[4]{14, 21, 23, 24}, array[4]{7, 15, 25, 26}, array[4]{8, 20, 25, 27}, array[4]{16, 21, 26, 27}, array[4]{9, 17, 28, 29}, array[4]{10, 22, 28, 30}, array[4]{18, 23, 29, 30}, array[4]{11, 25, 28, 31}, array[4]{19, 26, 29, 31}, array[4]{24, 27, 30, 31} }
- #declare SquareIndex = clock; // number between 0 and 23 for one of the 24 square faces
- #declare VerticesForSquare = VerticesBySquare[SquareIndex];
- #declare EdgesForSquare = EdgesBySquare[SquareIndex];
- ////////////////////////////////////////////////////////////////////////
- union{
- // ALL VERTICES AND EDGES (LIGHT)
- merge {
- // ALL VERTICES
- union{
- #for( Index, 0, 15 )
- #if(Index<8) #local R = RadVert; #else #local R = RadVert*RadScale; #end
- sphere{
- P[Index], R
- #if(VertexRankParities[Index])
- pigment{color rgbt<1, 0.8, 0.65, Transparency/.2> * .2}
- #else
- pigment{color rgbt<1, 0.8, 0.65, Transparency/.5> * .5}
- #end
- }
- #end
- }
- // ALL EDGES
- union{
- #for( Index, 0, 31 )
- #local EdgeArray = Edges[Index];
- #local A = EdgeArray[0];
- #local B = EdgeArray[1];
- #if(A<8) #local RadA = RadEdge; #else #local RadA = RadEdge*RadScale; #end
- #if(B<8) #local RadB = RadEdge; #else #local RadB = RadEdge*RadScale; #end
- cone{ P[A], RadA, P[B], RadB }
- #end
- pigment{color rgbt <.5, .5, .5, Transparency>}
- }
- }
- // SQUARE VERTICES
- union{
- #for( Index, 0, 3 )
- #local IndexInThisSquare = VerticesForSquare[Index];
- #if(IndexInThisSquare<8) #local R = RadVert+.0001; #else #local R = RadVert*RadScale+.0001; #end
- sphere{
- P[IndexInThisSquare], R+.0001
- #if(VertexRankParities[IndexInThisSquare])
- pigment{color rgb<1, 0.8, 0.65> * .2}
- #else
- pigment{color rgb<1, 0.8, 0.65> * .5}
- #end
- }
- #end
- }
- // SQUARE EDGES
- union{
- #for( Index, 0, 3 )
- #local EdgeArray = Edges[EdgesForSquare[Index]];
- #local A = EdgeArray[0];
- #local B = EdgeArray[1];
- #if(A<8) #local RadA = RadEdge+.0001; #else #local RadA = RadEdge*RadScale+.0001; #end
- #if(B<8) #local RadB = RadEdge+.0001; #else #local RadB = RadEdge*RadScale+.0001; #end
- cone{ P[A], RadA, P[B], RadB }
- #end
- pigment{color rgb .5}
- }
- // SQUARE FACE
- #local FaceArray = Faces[SquareIndex];
- polygon{
- 5, P[FaceArray[0]], P[FaceArray[1]], P[FaceArray[3]], P[FaceArray[2]], P[FaceArray[0]]
- pigment{color rgbt<0, 0, 1, .8>}
- }
- // VERTEX LABELS
- #for( Index, 0, 15 )
- text { ttf "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", str(Index,2,0), .03, 0
- #if(Index<8) scale .11 #else scale .085 #end // labels for the inner cube are smaller
- translate P[Index] // move label from center to vertex
- #if(Index<8) // OUTSIDE
- #if(mod(div(Index,4),2)) // RIGHT
- translate .1*x
- #else // LEFT
- translate -.1*x
- #end
- #if(mod(Index, 2)) // TOP
- translate .068*y
- #else // BOTTOM
- translate -.068*y
- #end
- translate <-.063, -.035, 0>
- #else // INSIDE
- #if(mod(div(Index,4),2)) // RIGHT
- translate -.08*x
- #else // LEFT
- translate .08*x
- #end
- #if(mod(Index, 2)) // TOP
- translate -.062*y
- #else // BOTTOM
- translate .062*y
- #end
- translate <-.05, -.032, 0>
- #end
- #if(!is_in(Index, VerticesForSquare))
- pigment{ color rgbt .7 }
- #end
- }
- #end
- scale 2.25
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement