Povray code-gaddid-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/>
 \*/

/\* Great dodecicosidodecahedron regiment \*/

#include "ike-sym.inc"

// Vertices
#declare NumVertices = 60;
#declare NumVirtualVertices = 5 \* 12 + 20 \* 12;
#declare Vertices = array[NumVertices + NumVirtualVertices];

#local Phi3 = Phi \* Phi \* Phi;
#local Alpha = 1 / Phi;
#local Beta = 1 / Phi3;
#for (E, 0, NumIkeEdges - 1, 1)
 #local V0 = IkeVertices[IkeEdges[E][0]];
 #local V1 = IkeVertices[IkeEdges[E][1]];
 #declare Vertices[2 \* E ] = V0 \* Alpha + V1 \* Beta;
 #declare Vertices[2 \* E + 1] = V1 \* Alpha + V0 \* Beta;
#end
#declare Circumradius = sqrt(11 - 4 \* sqrt(5));

// Edges
#declare NumEdges = 120;
#declare Edges = array[NumEdges][2];

#for (F, 0, NumDoeFullFaces - 1, 1)
 #local DecEdges = array[5];
 #for (IF, 0, 4, 1)
 #local Ike = DoeFullFaces[F][IF];
 #for (V, 0, 2, 1)
 #if (IkeFaces[Ike][V] = F)
 #local V1 = IkeFaces[Ike][mod(V + 2, 3)];
 #local V2 = IkeFaces[Ike][mod(V + 1, 3)];
 #for (E, 0, 2 \* NumIkeEdges - 1, 1)
 #if (V1 = IkeDoubleEdges[E][0] & V2 = IkeDoubleEdges[E][1])
 #declare DecEdges[IF] = E;
 #end
 #end
 #end
 #end
 #end
 #for (V, 0, 9, 1)
 #local IkeEdge = mod(floor(V \* 1.5), 5);
 #local End = mod(V, 2);
 #local DE = DecEdges[IkeEdge];
 #local Vert = 2 \* mod(DE, NumIkeEdges);
 #if (DE >= NumIkeEdges)
 #declare Vert = Vert + 1 - End;
 #else
 #declare Vert = Vert + End;
 #end
 #declare Edges[10 \* F + V][0] = Vert;
 #declare Edges[10 \* F + mod(V + 1, 10)][1] = Vert;
 #end
#end

// Full Faces
#declare DecFullFacesStart = 0;
#declare NumDecFullFaces = NumDoeFullFaces;
#declare TriFullFacesStart = DecFullFacesStart + NumDecFullFaces;
#declare NumTriFullFaces = NumIkeFaces;
#declare PentFullFacesStart = TriFullFacesStart + NumTriFullFaces;
#declare NumPentFullFaces = NumDoeFullFaces;
#declare SquareFullFacesStart = PentFullFacesStart + NumPentFullFaces;
#declare NumSquareFullFaces = NumDoeEdges;

#declare NumFullFaces = SquareFullFacesStart + NumSquareFullFaces;
#declare FullFaces = array[NumFullFaces][10];
#declare FullFaceSizes = array[NumFullFaces];

// Decagram
#for (F, 0, NumDecFullFaces - 1, 1)
 #local To = F + DecFullFacesStart;
 #for (V, 0, 9, 1)
 #declare FullFaces[To][V] = Edges[10 \* F + V][0];
 #end
 #declare FullFaceSizes[To] = 10;
#end

// Triangles
#for (F, 0, NumTriFullFaces - 1, 1)
 #local To = TriFullFacesStart + F;
 #local Tri = array[5];
 #for (V, 0, 2, 1)
 #declare Tri[V] = IkeFaces[F][V];
 #end
 #declare Tri[3] = Tri[0];
 #declare Tri[4] = Tri[1];
 #for (IV, 0, 2, 1)
 #local T = Tri[IV];
 #for (DV, 0, 4, 1)
 #if (DoeFullFaces[T][DV] = F)
 #local DFE = DoeFaceEdges[T][mod(DV + 2, 5)];
 #local Vtx = 2 \* mod(DFE, NumIkeEdges) + floor(DFE / NumIkeEdges);
 #declare FullFaces[To][IV] = Vtx;
 #end
 #end
 #end
 #declare FullFaceSizes[To] = 3;
#end

// Pentagrams
#for (F, 0, NumPentFullFaces - 1, 1)
 #local To = PentFullFacesStart + F;
 #for (V, 0, 4, 1)
 #local IF = DoeFullFaces[F][mod(V \* 2, 5)];
 #for (VV, 0, 2, 1)
 #if (IkeFaces[IF][VV] = F)
 #local Edge = IkeFaceEdges[IF][mod(VV + 1, 3)];
 #local Value = 2 \* mod(Edge, NumIkeEdges);
 #local End = floor(Edge / NumIkeEdges);
 #declare FullFaces[To][V] = Value + 1 - End;
 #end
 #end
 #end
 #declare FullFaceSizes[To] = 5;
#end

// Squares
#local EdgesUsed = array[NumEdges];
#for (E, 0, NumEdges - 1, 1)
 #declare EdgesUsed[E] = false;
#end
#local LastUnusedEdge = -1;
#for (F, 0, NumSquareFullFaces - 1, 1)
 #declare LastUnusedEdge = LastUnusedEdge + 1;
 #declare To = F + SquareFullFacesStart;
 #while (EdgesUsed[LastUnusedEdge])
 #declare LastUnusedEdge = LastUnusedEdge + 1;
 #end
 #declare EdgesUsed[LastUnusedEdge] = true;
 #local Vert = Vertices[Edges[LastUnusedEdge][0]];
 #local ThisVert = Edges[LastUnusedEdge][1];
 #declare FullFaces[To][0] = ThisVert;
 #for (V, 1, 3, 1)
 #local NextVert = -1;
 #local NextEdge = -1;
 #for (E, LastUnusedEdge + 1, NumEdges - 1, 1)
 #if (!EdgesUsed[E])
 #if (Edges[E][0] = ThisVert &
 vlength(Vert - Vertices[Edges[E][1]]) > 2.5)
 #declare NextEdge = E;
 #declare NextVert = Edges[E][1];
 #elseif (Edges[E][1] = ThisVert &
 vlength(Vert - Vertices[Edges[E][0]]) > 2.5)
 #declare NextEdge = E;
 #declare NextVert = Edges[E][0];
 #end
 #end
 #end
 #declare EdgesUsed[NextEdge] = true;
 #declare FullFaces[To][V] = NextVert;
 #declare Vert = Vertices[ThisVert];
 #declare ThisVert = NextVert;
 #end
 #declare FullFaceSizes[To] = 4;
#end

// Faces
#include "macros.inc"

#declare NumDecFaces = NumDecFullFaces \* NumPieces10\_3;
#declare DecFaces = array[NumDecFaces][3];
Triangulate10\_3(DecFaces, 0, DecFullFacesStart, NumDecFullFaces)

#declare NumTriFaces = NumTriFullFaces;
#declare TriFaces = array[NumTriFaces][3];
TriangulateConvex(TriFaces, 0, TriFullFacesStart, NumTriFullFaces,3)

#declare NumPentFaces = NumPentFullFaces \* NumPieces5\_2;
#declare PentFaces = array[NumPentFaces][3];
Triangulate5\_2(PentFaces, 0, PentFullFacesStart, NumPentFullFaces)

#declare NumSquareFaces = 2 \* NumSquareFullFaces;
#declare SquareFaces = array[NumSquareFaces][3];
TriangulateConvex(SquareFaces, 0, SquareFullFacesStart,
 NumSquareFullFaces, 4)

```