Povray code-siid-reg.inc

```
/\* This program is free software: you can redistribute it and/or modify it
 \* under the terms of the GNU General Public License as published by the Free
 \* Software Foundation, either version 3 of the License, or (at your option)
 \* any later version.
 \*
 \* This program is distributed in the hope that it will be useful, but WITHOUT
 \* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 \* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 \* more details.
 \*
 \* You should have received a copy of the GNU General Public License along with
 \* this program. If not, see <http://www.gnu.org/licenses/>
 \*/

/\* Small icosicosidodecahedron regiment \*/

#include "ike-sym.inc"

#declare NumVertices = 60;
#declare NumVirtualVertices = 5 \* NumDoeFullFaces;
#declare Vertices = array[NumVertices + NumVirtualVertices];

#include "macros.inc"

#local Scale = Phi \* Phi \* sqrt(5);;
#for (F, 0, NumDoeFullFaces - 1, 1)
 #local Central = <0, 0, 0>;
 #for (V, 0, 4, 1)
 #declare Central = Central + DoeVertices[DoeFullFaces[F][V]];
 #end
 #declare Central = Central / Scale;
 #for (V, 0, 4, 1)
 #declare Vertices[5 \* F + V] =
 DoeVertices[DoeFullFaces[F][mod(2 \* V, 5)]] / Phi +
 Central;
 #end
#end
#declare Circumradius = sqrt((17 + 3 \* sqrt(5)) / 2);

#declare NumEdges = 5 \* NumDoeFullFaces + 3 \* NumDoeVertices;
#declare Edges = array[NumEdges][2];
#for (E, 0, NumVertices - 1, 1)
 #declare Edges[E][0] = E;
 #declare Edges[E][1] = 5 \* floor(E / 5) + mod(E + 1, 5);
#end
#for (E, 0, NumDoeVertices - 1, 1)
 #local To = 3 \* E + NumVertices;
 #for (F, 0, 2, 1)
 #local DoeFace = IkeFaces[E][F];
 #for (V, 0, 4, 1)
 #if (DoeFullFaces[DoeFace][V] = E)
 #local Edge = 5 \* DoeFace + mod(3 \* V, 5);
 #declare Edges[To + F][1] = Edge;
 #declare Edges[To + mod(F + 1, 3)][0] = Edge;
 #end
 #end
 #end
#end

#declare PentFullFacesStart = 0;
#declare NumPentFullFaces = NumDoeFullFaces;
#declare TriFullFacesStart = PentFullFacesStart + NumPentFullFaces;
#declare NumTriFullFaces = NumDoeVertices;
#declare HexFullFacesStart = TriFullFacesStart + NumTriFullFaces;
#declare NumHexFullFaces = NumDoeVertices;
#declare DecFullFacesStart = HexFullFacesStart + NumHexFullFaces;
#declare NumDecFullFaces = NumDoeFullFaces;
#declare NumFullFaces = DecFullFacesStart + NumDecFullFaces;
#declare FullFaces = array[NumFullFaces][10];
#declare FullFaceSizes = array[NumFullFaces];

// Pentagrams
#for (F, 0, NumPentFullFaces - 1, 1)
 #local To = PentFullFacesStart + F;
 #for (V, 0, 4, 1)
 #declare FullFaces[To][V] = 5 \* F + V;
 #end
 #declare FullFaceSizes[To] = 5;
#end

// Triangles
#for (F, 0, NumTriFullFaces - 1, 1)
 #local To = TriFullFacesStart + F;
 #local From = NumVertices + 3 \* F;
 #for (V, 0, 2, 1)
 #declare FullFaces[To][V] = Edges[From + V][0];
 #end
 #declare FullFaceSizes[To] = 3;
#end

// Hexagons
#for (F, 0, NumHexFullFaces - 1, 1)
 #local Verts = array[6];
 #local To = HexFullFacesStart + F;
 #for (V, 0, 2, 1)
 #local Pent = IkeFaces[F][V];
 #for (VV, 0, 4, 1)
 #if (DoeFullFaces[Pent][VV] = F)
 #declare Verts[2 \* V ] = 5 \* Pent + mod(3 \* VV + 2, 5);
 #declare Verts[2 \* V + 1] = 5 \* Pent + mod(3 \* VV + 3, 5);
 #end
 #end
 #end
 SortPairs(Verts, 6)
 #for (V, 0, 5, 1)
 #declare FullFaces[To][V] = Verts[V];
 #end
 #declare FullFaceSizes[To] = 6;
#end

// Decagons
#local EdgesUsed = array[NumEdges];
#local LastEdgeUsed = -1;
#for (E, 0, NumEdges - 1, 1)
 #declare EdgesUsed[E] = false;
#end
#for (F, 0, NumDecFullFaces - 1, 1)
 #local To = DecFullFacesStart + F;
 #declare LastEdgeUsed = LastEdgeUsed + 1;
 #while (EdgesUsed[LastEdgeUsed])
 #declare LastEdgeUsed = LastEdgeUsed + 1;
 #end
 #declare EdgesUsed[LastEdgeUsed] = true;
 #local LastVtx = Vertices[Edges[LastEdgeUsed][0]];
 #local This = Edges[LastEdgeUsed][1];
 #declare FullFaces[To][0] = This;
 #for (V, 1, 9, 1)
 #local Next = -1;
 #local NextE = -1;
 #for (E, LastEdgeUsed + 1, NumEdges - 1, 1)
 #if (!EdgesUsed[E])
 #if (Edges[E][0] = This &
 vlength(LastVtx - Vertices[Edges[E][1]]) > 3.5)
 #declare NextE = E;
 #declare Next = Edges[E][1];
 #elseif (Edges[E][1] = This &
 vlength(LastVtx - Vertices[Edges[E][0]]) > 3.5)
 #declare NextE = E;
 #declare Next = Edges[E][0];
 #end
 #end
 #end
 #if (Next = -1)
 #error "Cannot find decagon"
 #end
 #declare EdgesUsed[NextE] = true;
 #declare FullFaces[To][V] = Next;
 #declare LastVtx = Vertices[This];
 #declare This = Next;
 #end
 #declare FullFaceSizes[To] = 10;
#end

// Split full faces
#declare NumTriFaces = NumTriFullFaces;
#declare TriFaces = array[NumTriFaces][3];
#declare NumPentFaces = NumPentFullFaces \* NumPieces5\_2;
#declare PentFaces = array[NumPentFaces][3];
#declare NumHexFaces = 4 \* NumHexFullFaces;
#declare HexFaces = array[NumHexFaces][3];
#declare NumDecFaces = 8 \* NumDecFullFaces;
#declare DecFaces = array[NumDecFaces][3];

TriangulateConvex(TriFaces, 0, TriFullFacesStart, NumTriFullFaces, 3)
Triangulate5\_2(PentFaces, 0, PentFullFacesStart, NumPentFullFaces)
TriangulateConvex(HexFaces, 0, HexFullFacesStart, NumHexFullFaces, 6)
TriangulateConvex(DecFaces, 0, DecFullFacesStart, NumDecFullFaces, 10)

```