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

/\* Augmented dodecahedra \*/
#include "poly-textures.inc"

#include "ike-sym.inc"

/\* Augment faces of dodecahedron with pyramids as follows:
 \* AugmentBase: < φ, 1, 0> (0)
 \* AugmentPara: <-φ, -1, 0> (3)
 \* AugmentMeta: <-φ, 1, 0> (2)
 \* AugmentThird: < 0, -φ, 1> (10)
 \*/

#local Phi2 = Phi \* Phi;
#local Phi4 = Phi2 \* Phi2;
#local Phi5 = Phi4 \* Phi;

#local NumAugments = 0;
#local AugmentIndex = array[5];
#ifdef (AugmentBase)
 #declare AugmentIndex[NumAugments] = 0;
 #declare NumAugments = 1;
#end
#ifdef (AugmentMeta)
 #declare AugmentIndex[NumAugments] = 2;
 #declare NumAugments = NumAugments + 1;
#end
#ifdef (AugmentPara)
 #declare AugmentIndex[NumAugments] = 3;
 #declare NumAugments = NumAugments + 1;
#end
#ifdef (AugmentThird)
 #declare AugmentIndex[NumAugments] = 10;
 #declare NumAugments = NumAugments + 1;
#end
#declare AugmentIndex[NumAugments] = -1;

// Vertices
#declare NumVertices = NumDoeVertices + NumAugments;
#declare Vertices = array[NumVertices];

#local DoeInradius = sqrt(Phi5 / sqrt(5));
#local PentCircumradius = 2 \* sqrt(Phi / sqrt(5));
// PH = 4 (1 - φ / sqrt(5))
#local PyramidHeight = sqrt(4 - PentCircumradius \* PentCircumradius);
#declare Circumradius = DoeInradius + PyramidHeight;
#local IkeCircumradius = sqrt(Phi \* sqrt(5));
#local Scale = Circumradius / IkeCircumradius;

#for (V, 0, NumDoeVertices - 1, 1)
 #declare Vertices[V] = DoeVertices[V];
#end
#for (V, 0, NumAugments - 1, 1)
 #declare Vertices[V + NumDoeVertices] = IkeVertices[AugmentIndex[V]] \*
 Scale;
#end

// Edges
#declare NumEdges = NumDoeEdges + 5 \* NumAugments;
#declare Edges = array[NumEdges][2];

#for (E, 0, NumDoeEdges - 1, 1)
 #declare Edges[E][0] = DoeEdges[E][0];
 #declare Edges[E][1] = DoeEdges[E][1];
#end
#for (F, 0, NumAugments - 1, 1)
 #local Face = AugmentIndex[F];
 #local To = NumDoeEdges + F \* 5;
 #for (V, 0, 4, 1)
 #declare Edges[To + V][0] = DoeFullFaces[Face][V];
 #declare Edges[To + V][1] = NumDoeVertices + F;
 #end
#end

// Full Faces
#declare NumFullFaces = NumDoeFullFaces + 4 \* NumAugments;
#declare FullFaces = array[NumFullFaces][5];
#declare FullFaceSizes = array[NumFullFaces];
#declare FullFaceTextures = array[NumFullFaces];

#local NextAugment = 0;
#for (F, 0, NumDoeFullFaces - 1, 1)
 #declare FullFaces[F][0] = DoeFullFaces[F][4];
 #declare FullFaces[F][1] = DoeFullFaces[F][0];
 #if (F = AugmentIndex[NextAugment])
 #local Apex = NumDoeVertices + NextAugment;
 #declare FullFaces[F][2] = Apex;
 #declare FullFaceSizes[F] = 3;
 #declare FullFaceTextures[F] = 1;
 #local To = NumDoeFullFaces + 4 \* NextAugment;
 #for (FF, 0, 3, 1)
 #declare FullFaces[To + FF][0] = DoeFullFaces[F][FF];
 #declare FullFaces[To + FF][1] = DoeFullFaces[F][FF + 1];
 #declare FullFaces[To + FF][2] = Apex;
 #declare FullFaceSizes[To + FF] = 3;
 #declare FullFaceTextures[To + FF] = DualTexture;
 #end
 #declare NextAugment = NextAugment + 1;
 #else
 #for (V, 2, 4, 1)
 #declare FullFaces[F][V] = DoeFullFaces[F][V - 1];
 #end
 #declare FullFaceSizes[F] = 5;
 #declare FullFaceTextures[F] = BaseTexture;
 #end
#end

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

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

```