Povray code-gidditdid-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 ditrigonary dodecicosidodecahedron regimant \*/

#include "ike-sym.inc"

#declare NumVertices = 2 \* NumDoeEdges;
#declare NumVirtualVertices = 240; // 12 x 20
#declare Vertices = array[NumVertices + NumVirtualVertices];

// Vertices
#local Phi2 = Phi \* Phi;
#local Phi3 = Phi2 \* Phi;
#local Alpha = 1 / Phi;
#local Beta = 1 / Phi3;
#for (F, 0, NumDoeEdges - 1, 1)
 #local V1 = DoeVertices[DoeEdges[F][0]];
 #local V2 = DoeVertices[DoeEdges[F][1]];
 #declare Vertices[2 \* F ] = V1 \* Alpha + V2 \* Beta;
 #declare Vertices[2 \* F + 1] = V2 \* Alpha + V1 \* Beta;
#end
#declare Circumradius = sqrt((17 - 3 \* sqrt(5)) / 2);

// Edges
#declare NumEdges = 10 \* NumDoeFullFaces;
#declare Edges = array[NumEdges][2];
#for (F, 0, NumDoeFullFaces - 1, 1)
 #local Offset = 10 \* F;
 #for (E, 0, 9, 1)
 #local EdgeNo = mod(floor(E \* 1.5), 5);
 #local End = mod(E, 2);
 #local DFE = DoeFaceEdges[F][EdgeNo];
 #if (DFE >= NumDoeEdges)
 #declare DFE = DFE - NumDoeEdges;
 #declare End = 1 - End;
 #end
 #declare Edges[Offset + E][1] = 2 \* DFE + End;
 #declare Edges[Offset + mod(E + 1, 10)][0] = 2 \* DFE + End;
 #end
#end

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

// Decagrams
#for (F, 0, NumDecFullFaces - 1, 1)
 #local To = DecFullFacesStart + F;
 #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;
 #for (E, 0, 2, 1)
 #local IE = mod(IkeFaceEdges[F][E], NumIkeEdges);
 #local End = (DoeEdges[IE][0] = F ? 1 : 0);
 #declare FullFaces[To][E] = 2 \* IE + End;
 #declare FullFaceSizes[To] = 3;
 #end
#end

// Pentagons
#for (F, 0, NumPentFullFaces - 1, 1)
 #local To = PentFullFacesStart + F;
 #for (V, 0, 4, 1)
 #local E1 = mod(DoeFaceEdges[F][V], NumDoeEdges);
 #local E2 = mod(DoeFaceEdges[F][mod(V + 1, 5)], NumDoeEdges);
 #local Vtx = DoeFullFaces[F][mod(V + 1, 5)];
 #local Edge = -1;
 #for (IV, 0, 2, 1)
 #local IE = IkeFaceEdges[Vtx][IV];
 #if (mod(IE - E1, NumIkeEdges) != 0 & mod(IE - E2, NumIkeEdges) != 0)
 #declare Edge = IE;
 #end
 #end
 #declare FullFaces[To][V] = 2 \* mod(Edge, NumIkeEdges) +
 floor(Edge / NumIkeEdges);
 #end
 #declare FullFaceSizes[To] = 5;
#end

// Hexagons
#for (F, 0, NumHexFullFaces - 1, 1)
 #local To = HexFullFacesStart + F;
 #local Vtx = array[6];
 #local IV = IkeVertices[IkeFaces[F][0]] + IkeVertices[IkeFaces[F][1]] +
 IkeVertices[IkeFaces[F][2]];
 #for (V, 0, 2, 1)
 #local IFE = mod(IkeFaceEdges[F][V], NumIkeEdges);
 #local Tri = DoeEdges[IFE][0] + DoeEdges[IFE][1] - F;
 #local NextVtx = 2 \* V;
 #for (VV, 0, 2, 1)
 #local FF = FullFaces[TriFullFacesStart + Tri][VV];
 #if (vlength(Vertices[FF] - IV) = 4)
 #declare Vtx[NextVtx] = FF;
 #declare NextVtx = NextVtx + 1;
 #end
 #end
 #if (NextVtx != 2 \* V + 2)
 #error "Vertex error"
 #end
 #end
 #local V0 = Vertices[Vtx[0]];
 #local V2 = Vertices[Vtx[2]];
 #local V3 = Vertices[Vtx[3]];
 #if (vlength(V0 - V2) = 2 | vlength(V0 - V3) = 2)
 #local Temp = Vtx[0];
 #declare Vtx[0] = Vtx[1];
 #declare Vtx[1] = Temp;
 #end
 #for (V, 2, 4, 2)
 #if (vlength(Vertices[Vtx[V - 1]] - Vertices[Vtx[V]]) != 2)
 #local Temp = Vtx[V];
 #declare Vtx[V] = Vtx[V + 1];
 #declare Vtx[V + 1] = Temp;
 #end
 #end
 #for (V, 0, 5, 1)
 #declare FullFaces[To][V] = Vtx[V];
 #end
 #declare FullFaceSizes[To] = 6;
#end

#include "macros.inc"
#declare NumFullFaces = HexFullFacesStart;

#declare NumDecFaces = NumPieces10\_3 \* NumDecFullFaces;
#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 = 3 \* NumPentFullFaces;
#declare PentFaces = array[NumPentFaces][3];
TriangulateConvex(PentFaces, 0, PentFullFacesStart, NumPentFullFaces, 5)

#declare NumHexFaces = 4 \* NumHexFullFaces;
#declare HexFaces = array[NumHexFaces][3];
TriangulateConvex(HexFaces, 0, HexFullFacesStart, NumHexFullFaces, 6)

```