Povray code-sirco-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 rhombicuboctahedron regiment \*/

#include "oct-sym.inc"

#declare NumVertices = 3 \* NumCubeVertices;
#declare Vertices = array[NumVertices];

#for (F, 0, NumCubeFullFaces - 1, 1)
 #for (V, 0, 3, 1)
 #local Vertex = CubeFullFaces[F][V];
 #declare Vertices[4 \* F + V] = CubeVertices[Vertex] + OctVertices[F];
 #end
#end

#declare Circumradius = sqrt(5 + 2 \* sqrt(2));

// Edges
#declare NumEdges = 4 \* NumCubeFullFaces + 3 \* NumOctFaces;
#declare Edges = array[NumEdges][2];

#local TriBase = 4 \* NumCubeFullFaces;
#for (F, 0, NumCubeFullFaces - 1, 1)
 #for (E, 0, 3, 1)
 #local Ofs = 4 \* F + E;
 #declare Edges[Ofs][0] = Ofs;
 #declare Edges[Ofs][1] = 4 \* F + mod(E + 1, 4);
 #end
#end

#for (F, 0, NumOctFaces - 1, 1)
 #for (E, 0, 2, 1)
 #local Face = OctFaces[F][E];
 #for (FF, 0, 3, 1)
 #if (CubeFullFaces[Face][FF] = F)
 #declare Edges[TriBase + 3 \* F + E][0] = 4 \* Face + FF;
 #declare Edges[TriBase + 3 \* F + mod(E + 1, 3)][1] = 4 \* Face + FF;
 #end
 #end
 #end
#end

// Full Faces
#declare SquareFullFacesStart = 0;
#declare NumSquareFullFaces = NumCubeFullFaces;
#declare TriangleFullFacesStart = SquareFullFacesStart + NumSquareFullFaces;
#declare NumTriangleFullFaces = NumOctFaces;
#declare RhombFullFacesStart = TriangleFullFacesStart + NumTriangleFullFaces;
#declare NumRhombFullFaces = NumCubeEdges;
#declare OctagonFullFacesStart = RhombFullFacesStart + NumRhombFullFaces;
#declare NumOctagonFullFaces = NumCubeFullFaces;
#declare NumFullFaces = OctagonFullFacesStart + NumOctagonFullFaces;
#declare FullFaces = array[NumFullFaces][8];
#declare FullFaceSizes = array[NumFullFaces];

#include "macros.inc"

// Square
#for (F, 0, NumSquareFullFaces - 1, 1)
 #local To = SquareFullFacesStart + F;
 #for (V, 0, 3, 1)
 #declare FullFaces[To][V] = 4 \* F + V;
 #end
 #declare FullFaceSizes[To] = 4;
#end

// Triangle
#for (F, 0, NumTriangleFullFaces - 1, 1)
 #local To = TriangleFullFacesStart + F;
 #for (V, 0, 2, 1)
 #local Face = OctFaces[F][V];
 #for (FF, 0, 3, 1)
 #if (CubeFullFaces[Face][FF] = F)
 #declare FullFaces[To][V] = 4 \* Face + FF;
 #end
 #end
 #end
 #declare FullFaceSizes[To] = 3;
#end

// Rhomb
#for (F, 0, NumRhombFullFaces - 1, 1)
 #local To = RhombFullFacesStart + F;
 #local CubeFaceA = OctEdges[F][0];
 #local CubeFaceB = OctEdges[F][1];
 #local OctFaceA = CubeEdges[F][0];
 #local OctFaceB = CubeEdges[F][1];
 #local Vert = array[4];
 #for (V, 0, 3, 1)
 #if (CubeFullFaces[CubeFaceA][V] = OctFaceA)
 #declare Vert[0] = 4 \* CubeFaceA + V;
 #else
 #if (CubeFullFaces[CubeFaceA][V] = OctFaceB)
 #declare Vert[1] = 4 \* CubeFaceA + V;
 #end
 #end
 #if (CubeFullFaces[CubeFaceB][V] = OctFaceA)
 #declare Vert[2] = 4 \* CubeFaceB + V;
 #else
 #if (CubeFullFaces[CubeFaceB][V] = OctFaceB)
 #declare Vert[3] = 4 \* CubeFaceB + V;
 #end
 #end
 #end
 #declare FullFaces[To][0] = Vert[0];
 #declare FullFaces[To][1] = Vert[1];
 #if (vlength(Vertices[Vert[0]] - Vertices[Vert[3]]) > 3)
 #declare FullFaces[To][2] = Vert[2];
 #declare FullFaces[To][3] = Vert[3];
 #else
 #declare FullFaces[To][2] = Vert[3];
 #declare FullFaces[To][3] = Vert[2];
 #end
 #declare FullFaceSizes[To] = 4;
#end

// Octagon
#for (F, 0, NumOctagonFullFaces - 1, 1)
 #local To = OctagonFullFacesStart + F;
 #for (E, 0, 3, 1)
 #local Edge = mod(CubeFaceEdges[F][E], NumCubeEdges);
 #local AdjFace = OctEdges[Edge][0] + OctEdges[Edge][1] - F;
 #for (EE, 0, 3, 1)
 #if (mod(CubeFaceEdges[AdjFace][EE], NumCubeEdges) = Edge)
 #declare FullFaces[To][2 \* E] = 4 \* AdjFace + mod(EE + 1, 4);
 #declare FullFaces[To][2 \* E + 1] = 4 \* AdjFace + EE;
 #end
 #end
 #end
 #declare FullFaceSizes[To] = 8;
#end

// Faces
#declare NumSquareFaces = 2 \* NumSquareFullFaces;
#declare NumTriangleFaces = NumTriangleFullFaces;
#declare NumRhombFaces = 2 \* NumRhombFullFaces;
#declare NumOctagonFaces = 6 \* NumOctagonFullFaces;

#declare SquareFaces = array[NumSquareFaces][3];
#declare TriangleFaces = array[NumTriangleFaces][3];
#declare RhombFaces = array[NumRhombFaces][3];
#declare OctagonFaces = array[NumOctagonFaces][3];

TriangulateConvex(SquareFaces, 0, SquareFullFacesStart, NumSquareFullFaces, 4)
TriangulateConvex(TriangleFaces, 0, TriangleFullFacesStart,
 NumTriangleFullFaces, 3)
TriangulateConvex(RhombFaces, 0, RhombFullFacesStart, NumRhombFullFaces, 4)
TriangulateConvex(OctagonFaces, 0, OctagonFullFacesStart, NumOctagonFullFaces,

```