Povray code-j-ike.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/>
 \*/

/\* Diminished icosahedra \*/
#include "poly-textures.inc"

#include "ike-sym.inc"

#local Phi2 = Phi \* Phi;

#local VerticesStatus = array[NumIkeVertices];
#local FacesStatus = array[NumIkeFaces];

#for (V, 0, NumIkeVertices - 1, 1)
 #declare VerticesStatus[V] = 0;
#end

#for (F, 0, NumIkeFaces - 1, 1)
 #declare FacesStatus[F] = 0;
#end

#local NumDiminishings = 0;
#declare DiminishedVertices = array[4];
#macro Diminish(Vertex)
 #declare VerticesStatus[Vertex] = -1;
 #for (F, 0, 4, 1)
 #declare FacesStatus[DoeFullFaces[Vertex][F]] = -1;
 #end
 #declare DiminishedVertices[NumDiminishings] = Vertex;
 #declare NumDiminishings = NumDiminishings + 1;
#end

#ifdef (DiminishBase)
 Diminish(0)
#end
#ifdef (DiminishPara)
 Diminish(3)
#end
#ifdef (DiminishMeta)
 Diminish(2)
#end
#ifdef (DiminishThird)
 Diminish(10)
#end
#declare DiminishedVertices[NumDiminishings] = -1;

#declare AugmentedFaces = array[2];
#local NumAugmentings = 0;
#ifdef (Augment)
 #declare FacesStatus[0] = 1;
 #declare NumAugmentings = 1;
 #declare AugmentedFaces[0] = 0;
#end
#declare AugmentedFaces[NumAugmentings] = -1;

// Vertices
#declare NumVertices = NumIkeVertices - NumDiminishings + NumAugmentings;
#declare Vertices = array[NumVertices];
#local VertexMap = array[NumIkeVertices];
#local InverseMap = array[NumIkeVertices - NumDiminishings];
#local NextVertex = 0;
#for (V, 0, NumIkeVertices - 1, 1)
 #if (VerticesStatus[V] = 0)
 #declare Vertices[NextVertex] = IkeVertices[V];
 #declare VertexMap[V] = NextVertex;
 #declare InverseMap[NextVertex] = V;
 #declare NextVertex = NextVertex + 1;
 #end
#end
#local IkeInradius = Phi2 / sqrt(3);
#local TriangleCircumradius = 2 / sqrt(3);
#local TC2 = TriangleCircumradius \* TriangleCircumradius;
#local TetrahedronAltitude = sqrt(4 - TC2);
#local AugmentCircumradius = IkeInradius + TetrahedronAltitude;
#local DoeCircumradius = Phi \* sqrt(3);
#declare Scale = AugmentCircumradius / DoeCircumradius;
#for (V, 0, NumAugmentings - 1, 1)
 #declare Vertices[NextVertex] = DoeVertices[AugmentedFaces[V]] \* Scale;
 #declare NextVertex = NextVertex + 1;
#end

#if (NumAugmentings = 0)
 #declare Circumradius = sqrt(Phi \* sqrt(5));
#else
 #declare Circumradius = AugmentCircumradius;
#end

// Edges
#declare NumEdges = NumIkeEdges - 5 \* NumDiminishings + 3 \* NumAugmentings;
#declare Edges = array[NumEdges][2];

#local NextEdge = 0;
#for (E, 0, NumIkeEdges - 1, 1)
 #if (VerticesStatus[IkeEdges[E][0]] >= 0 &
 VerticesStatus[IkeEdges[E][1]] >= 0)
 #declare Edges[NextEdge][0] = VertexMap[IkeEdges[E][0]];
 #declare Edges[NextEdge][1] = VertexMap[IkeEdges[E][1]];
 #declare NextEdge = NextEdge + 1;
 #end
#end

#for (F, 0, NumAugmentings - 1, 1)
 #local Peak = NumIkeVertices - NumDiminishings + F;
 #local IkeFace = AugmentedFaces[F];
 #for (E, 0, 2, 1)
 #declare Edges[NextEdge][0] = VertexMap[IkeFaces[IkeFace][E]];
 #declare Edges[NextEdge][1] = Peak;
 #declare NextEdge = NextEdge + 1;
 #end
#end

// Full Faces
#declare NumFullFaces = NumIkeFaces - 4 \* NumDiminishings +
 2 \* NumAugmentings;
#declare FullFaces = array[NumFullFaces][5];
#declare FullFaceSizes = array[NumFullFaces];
#declare FullFaceTextures = array[NumFullFaces];

#local NextFullFace = 0;
#for (F, 0, NumIkeFaces - 1, 1)
 #if (FacesStatus[F] = 0)
 #for (V, 0, 2, 1)
 #declare FullFaces[NextFullFace][V] = VertexMap[IkeFaces[F][V]];
 #end
 #declare FullFaceSizes[NextFullFace] = 3;
 #declare FullFaceTextures[NextFullFace] = BaseTexture;
 #declare NextFullFace = NextFullFace + 1;
 #end
#end

#for (D, 0, NumDiminishings - 1, 1)
 #for (V, 0, 4, 1)
 #local DV = DiminishedVertices[D];
 #local Face = DoeFullFaces[DV][V];
 #for (FF, 0, 2, 1)
 #if (IkeFaces[Face][FF] = DV)
 #declare FullFaces[NextFullFace][V] =
 VertexMap[IkeFaces[Face][mod(FF + 1, 3)]];
 #end
 #end
 #end
 #declare FullFaceSizes[NextFullFace] = 5;
 #declare FullFaceTextures[NextFullFace] = MedialTexture;
 #declare NextFullFace = NextFullFace + 1;
#end

#for (F, 0, NumAugmentings - 1, 1)
 #local Face = AugmentedFaces[F];
 #local Peak = NumIkeVertices - NumDiminishings + F;
 #for (V, 0, 2, 1)
 #declare FullFaces[NextFullFace][0] = VertexMap[IkeFaces[Face][V]];
 #declare FullFaces[NextFullFace][1] =
 VertexMap[IkeFaces[Face][mod(V + 1, 3)]];
 #declare FullFaces[NextFullFace][2] = Peak;
 #declare FullFaceSizes[NextFullFace] = 3;
 #declare FullFaceTextures[NextFullFace] = MedialTexture;
 #declare NextFullFace = NextFullFace + 1;
 #end
#end

// Faces
#declare NumFaces = NumFullFaces + 2 \* NumDiminishings;
#declare Faces = array[NumFaces][3];
#declare FaceTextureIndex = array[NumFaces];

#local NextFace = 0;
#for (FF, 0, NumFullFaces - 1, 1)
 #for (F, 0, FullFaceSizes[FF] - 3, 1)
 #declare Faces[NextFace][0] = FullFaces[FF][0];
 #declare Faces[NextFace][1] = FullFaces[FF][F + 1];
 #declare Faces[NextFace][2] = FullFaces[FF][F + 2];
 #declare FaceTextureIndex[NextFace] = FullFaceTextures[FF];
 #declare NextFace = NextFace + 1;
 #end
#end

```