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;_cells
- // like
- // https://commons.wikimedia.org/wiki/File:Tesseract_cube_1.png
- // console command:
- // for i in `seq 0 7`; do povray tesseract_cubes.pov +ua +fn +H4000 +W3800 -D -k$i -Ocube_$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 VerticesByCube = array[8]{ array[8]{0, 1, 2, 3, 4, 5, 6, 7}, array[8]{0, 1, 2, 3, 8, 9, 10, 11}, array[8]{0, 1, 4, 5, 8, 9, 12, 13}, array[8]{0, 2, 4, 6, 8, 10, 12, 14}, array[8]{1, 3, 5, 7, 9, 11, 13, 15}, array[8]{2, 3, 6, 7, 10, 11, 14, 15}, array[8]{4, 5, 6, 7, 12, 13, 14, 15}, array[8]{8, 9, 10, 11, 12, 13, 14, 15} }
- #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} }
- #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} }
- #declare CubeIndex = clock; // number between 0 and 7 one of the 8 cubic cells
- #declare VerticesForCube = VerticesByCube[CubeIndex];
- #declare EdgesForCube = EdgesByCube[CubeIndex];
- #declare FacesForCube = FacesByCube[CubeIndex];
- ////////////////////////////////////////////////////////////////////////
- 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>}
- }
- }
- // CUBE VERTICES
- union{
- #for( Index, 0, 7 )
- #local IndexInThisCube = VerticesForCube[Index];
- #if(IndexInThisCube<8) #local R = RadVert+.0001; #else #local R = RadVert*RadScale+.0001; #end
- sphere{
- P[IndexInThisCube], R+.0001
- #if(VertexRankParities[IndexInThisCube])
- pigment{color rgb<1, 0.8, 0.65> * .2}
- #else
- pigment{color rgb<1, 0.8, 0.65> * .5}
- #end
- }
- #end
- }
- // CUBE EDGES
- union{
- #for( Index, 0, 11 )
- #local EdgeArray = Edges[EdgesForCube[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}
- }
- // CUBE FACES
- union{
- #for( Index, 0, 5 )
- #local FaceArray = Faces[FacesForCube[Index]];
- polygon{ 5, P[FaceArray[0]], P[FaceArray[1]], P[FaceArray[3]], P[FaceArray[2]], P[FaceArray[0]] }
- #end
- 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, VerticesForCube))
- pigment{ color rgbt .7 }
- #end
- }
- #end
- scale 2.25
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement