Povray code-oct-sym.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/>
 \*/

/\* Details for octahedral symmetry \*/

/\*\*\*\*\*\*\*\*
 \* \*
 \* Cube \*
 \* \*
 \*\*\*\*\*\*\*\*/
#declare NumCubeVertices = 8;
#declare NumCubeEdges = 12;
#declare NumCubeFullFaces = 6;
#declare NumCubeSplitFaces = 2 \* NumCubeFullFaces;
#declare CubeMidradius = sqrt(2);
#declare CubeCircumradius = sqrt(3);

#declare CubeVertices = array[NumCubeVertices] {
 <-1, -1, -1>,
 <-1, -1, 1>,
 <-1, 1, -1>,
 <-1, 1, 1>,
 < 1, -1, -1>,
 < 1, -1, 1>,
 < 1, 1, -1>,
 < 1, 1, 1>
};

#declare CubeEdges = array[NumCubeEdges][2] {
 {0, 1}, {0, 2}, {0, 4},
 {1, 3}, {1, 5}, {2, 3},
 {2, 6}, {3, 7}, {4, 5},
 {4, 6}, {5, 7}, {6, 7}
};

#declare CubeFullFaces = array[NumCubeFullFaces][4] {
 {0, 1, 3, 2}, {4, 6, 7, 5}, {0, 4, 5, 1},
 {2, 3, 7, 6}, {0, 2, 6, 4}, {1, 5, 7, 3}
};

#declare CubeFullFaceSizes = array[NumCubeFullFaces][2];
#declare CubeSplitFaces = array[NumCubeSplitFaces][3]
#for (F, 0, NumCubeFullFaces - 1, 1)
 #declare CubeFullFaceSizes[F][0] = 4; // i.e. Square = {4} = {4 / 1}
 #declare CubeFullFaceSizes[F][1] = 1;
#end

#for (F, 0, NumCubeFullFaces - 1, 1)
 #declare CubeSplitFaces[F \* 2 ][0] = CubeFullFaces[F][0];
 #declare CubeSplitFaces[F \* 2 ][1] = CubeFullFaces[F][1];
 #declare CubeSplitFaces[F \* 2 ][2] = CubeFullFaces[F][2];
 #declare CubeSplitFaces[F \* 2 + 1][0] = CubeFullFaces[F][0];
 #declare CubeSplitFaces[F \* 2 + 1][1] = CubeFullFaces[F][2];
 #declare CubeSplitFaces[F \* 2 + 1][2] = CubeFullFaces[F][3];
#end

#declare CubeVertexVertex = array[NumCubeVertices][3];
#for (V, 0, NumCubeVertices - 1, 1)
 #local NextVV = 0;
 #for (E, 0, NumCubeEdges - 1, 1)
 #if (CubeEdges[E][0] = V)
 #declare CubeVertexVertex[V][NextVV] = CubeEdges[E][1];
 #declare NextVV = NextVV + 1;
 #end
 #if (CubeEdges[E][1] = V)
 #declare CubeVertexVertex[V][NextVV] = CubeEdges[E][0];
 #declare NextVV = NextVV + 1;
 #end
 #end
#end

#declare CubeFaceEdges = array[NumCubeFullFaces][4];
#for (F, 0, NumCubeFullFaces - 1, 1)
 #for (V, 0, 3, 1)
 #local V1 = CubeFullFaces[F][V];
 #local V2 = CubeFullFaces[F][mod(V + 1, 4)];
 #for (E, 0, NumCubeEdges - 1, 1)
 (V1 = CubeEdges[E][1] & V2 = CubeEdges[E][0]))
 #declare CubeFaceEdges[F][V] = E;
 #end
 #end
 #end
#end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*
 \* \*
 \* Octahedron \*
 \* \*
 \*\*\*\*\*\*\*\*\*\*\*\*\*\*/
#declare NumOctVertices = 6;
#declare NumOctEdges = 12;
#declare NumOctFaces = 8;
#declare OctMidradius = 1;
#declare OctCircumradius = sqrt(2);

#declare OctVertices = array[NumOctVertices] {
 -sqrt(2) \* x, sqrt(2) \* x,
 -sqrt(2) \* y, sqrt(2) \* y,
 -sqrt(2) \* z, sqrt(2) \* z
};

#declare OctEdges = array[NumOctEdges][2] {
 {0, 2}, {0, 4}, {2, 4}, {0, 5},
 {2, 5}, {0, 3}, {3, 4}, {3, 5},
 {1, 2}, {1, 4}, {1, 5}, {1, 3}
};

#declare OctFaces = array[NumOctFaces][3] {
 {0, 2, 4}, {0, 5, 2},
 {0, 4, 3}, {0, 3, 5},
 {1, 4, 2}, {1, 2, 5},
 {1, 3, 4}, {1, 5, 3}
};

#declare OctFaceEdges = array[NumOctFaces][4];
#for (F, 0, NumOctFaces - 1, 1)
 #for (V, 0, 2, 1)
 #local V1 = OctFaces[F][V];
 #local V2 = OctFaces[F][mod(V + 1, 3)];
 #for (E, 0, NumOctEdges - 1, 1)
 (V1 = OctEdges[E][1] & V2 = OctEdges[E][0]))
 #declare OctFaceEdges[F][V] = E;
 #end
 #end
 #end
#end

```