POV-Ray : Newsgroups : povray.text.scene-files : Platonic solids (take two) Server Time
1 Jul 2024 03:02:24 EDT (-0400)
  Platonic solids (take two) (Message 1 to 2 of 2)  
From: Deaken
Subject: Platonic solids (take two)
Date: 18 Jan 2002 06:31:00
Message: <3C480797.A5FDACEB@sw-tech.com>
As mentioned in p.b.s-f.

Deaken

-----

// Persistence of Vision Ray Tracer Include File
// File: platonic.inc
// Vers: 0.99
// Desc: This file provides untextured versions of the five Platonic solids
//       (regular polyhedra) in three versions:
//       Poly_Faces [also just "Poly" with no suffix]
//           An object, centered at the origin, circumscribed by a notional
//           unit sphere.
//       Poly_Edges(R)
//           A macro, where R is the radius of the cylinders denoting the
//           edges of the polyhedron.
//       Poly_Vertices(R)
//           A macro, where R is the radius of the spheres placed at each
//           vertex of the polyhedron.
//       Where "Poly" is:
//           Tetrahedron
//           Cube
//           Octahedron
//           Dodecahedron
//           Icosahedron
//     As a side effect, the <X,Y,Z> vectors Poly_X are provided for each
//     object (starting at Poly_A and continuing through the Latin alphabet,
//     "Cube_A", "Tetra_D", "Dodeca_T", etc.), which are the coordinates
//     of each vertex of the object.  The suffix "-hedron" is eliminated
//     when the "Poly_X" vectors are named.
//     The last suffix of each shape is as follows:
//         Tetrahedron:   Tetra_D
//         Cube:          Cube_H
//         Octahedron:    Octa_F
//         Dodecahedron:  Dodeca_T
//         Icosahedron:   Icosa_L
//     In addition, the object Platonic_Bounding_Sphere and the macro
//     Platonic_Center_Sphere(R) are provided.
//     As a necessary scaling condition, Poly_Len and friends are also
//     also provided.  This is the length by which each polyhedron is scaled
//     to get it to fit into a unit sphere.  Multiply the Poly_X vectors by
//     it to get a polyhedron with unit sides.
//     
// Date: Jan 18 2002
// Auth: Deaken Wylie <dwy### [at] sw-techcom>
//
// Bugs: I do not provide "Hexahedron" as a synonym for "Cube".
//       I do not provide the vectors by which you can scale and rotate
//       the polyhedra to get them to rest flat on the Y plane.
//       These comments are WAY too verbose.

#macro Square ( P1, P2, P3, P4 )
  object {
    mesh {
      triangle {
        P1, P2, P3
      }
      triangle {
        P1, P3, P4
      }
    }
  }
#end

#macro Pentagon ( P1, P2, P3, P4, P5 )
  object {
    mesh {
      triangle {
        P1, P3, P4
      }
      triangle {
        P1, P2, P3
      }
      triangle {
        P1, P4, P5
      }
    }
  }
#end

#declare Tetra_First = < 1,  1,  1>;
#declare Tetra_Len = vlength ( Tetra_First );
#declare Tetra_A = < 1,  1,  1>/Tetra_Len;
#declare Tetra_B = <-1,  1, -1>/Tetra_Len;
#declare Tetra_C = < 1, -1, -1>/Tetra_Len;
#declare Tetra_D = <-1, -1,  1>/Tetra_Len;

#declare Tetrahedron = object {
  mesh {
    triangle {Tetra_A, Tetra_B, Tetra_C}
    triangle {Tetra_A, Tetra_B, Tetra_D}
    triangle {Tetra_A, Tetra_C, Tetra_D}
    triangle {Tetra_B, Tetra_C, Tetra_D}
  }
}
#declare Tetrahedron_Faces = object { Tetrahedron }
#macro Tetrahedron_Vertices ( R )
  object {
    union {
      sphere { Tetra_A, R }
      sphere { Tetra_B, R }
      sphere { Tetra_C, R }
      sphere { Tetra_D, R }
    }
  }             
#end
#macro Tetrahedron_Edges ( R )
  object {
    union {
      cylinder { Tetra_A, Tetra_B, R }
      cylinder { Tetra_A, Tetra_C, R }
      cylinder { Tetra_A, Tetra_D, R }
      cylinder { Tetra_B, Tetra_C, R }
      cylinder { Tetra_B, Tetra_D, R }
      cylinder { Tetra_C, Tetra_D, R }
    }
  }
#end

#declare Cube_First = < 1,  1,  1>;
#declare Cube_Len = vlength ( Cube_First );
#declare Cube_A = < 1,  1,  1>/Cube_Len;
#declare Cube_B = < 1,  1, -1>/Cube_Len;
#declare Cube_C = < 1, -1,  1>/Cube_Len;
#declare Cube_D = < 1, -1, -1>/Cube_Len;
#declare Cube_E = <-1,  1,  1>/Cube_Len;
#declare Cube_F = <-1,  1, -1>/Cube_Len;
#declare Cube_G = <-1, -1,  1>/Cube_Len;
#declare Cube_H = <-1, -1, -1>/Cube_Len;
#declare Cube = object {
  union {
    Square(Cube_A,Cube_B,Cube_D,Cube_C)
    Square(Cube_A,Cube_B,Cube_F,Cube_E)
    Square(Cube_A,Cube_C,Cube_G,Cube_E)
    Square(Cube_B,Cube_D,Cube_H,Cube_F)
    Square(Cube_C,Cube_D,Cube_H,Cube_G)
    Square(Cube_E,Cube_F,Cube_H,Cube_G)
  }
}
#declare Cube_Faces = object { Cube }
#macro Cube_Vertices ( R )
  object {
    union {
      sphere { Cube_A, R }
      sphere { Cube_B, R }
      sphere { Cube_C, R }
      sphere { Cube_D, R }
      sphere { Cube_E, R }
      sphere { Cube_F, R }
      sphere { Cube_G, R }
      sphere { Cube_H, R }
    }
  }
#end
#macro Cube_Edges ( R )
  object {
    union {
      cylinder { Cube_A, Cube_B, R }
      cylinder { Cube_A, Cube_C, R }
      cylinder { Cube_A, Cube_E, R }
      cylinder { Cube_B, Cube_D, R }
      cylinder { Cube_B, Cube_F, R }
      cylinder { Cube_C, Cube_D, R }
      cylinder { Cube_C, Cube_G, R }
      cylinder { Cube_D, Cube_H, R }
      cylinder { Cube_E, Cube_F, R }
      cylinder { Cube_E, Cube_G, R }
      cylinder { Cube_F, Cube_H, R }
      cylinder { Cube_G, Cube_H, R }
    }
  }
#end

#declare Octa_First = < 1,  0,  0>;
#declare Octa_Len = vlength ( Octa_First );
#declare Octa_A = < 1,  0,  0>/Octa_Len;
#declare Octa_B = <-1,  0,  0>/Octa_Len;
#declare Octa_C = < 0,  1,  0>/Octa_Len;
#declare Octa_D = < 0, -1,  0>/Octa_Len;
#declare Octa_E = < 0,  0,  1>/Octa_Len;
#declare Octa_F = < 0,  0, -1>/Octa_Len;
#declare Octahedron = object {
  mesh {
    triangle {Octa_A, Octa_C, Octa_E}
    triangle {Octa_A, Octa_C, Octa_F}
    triangle {Octa_A, Octa_D, Octa_E}
    triangle {Octa_A, Octa_D, Octa_F}
    triangle {Octa_B, Octa_C, Octa_E}
    triangle {Octa_B, Octa_C, Octa_F}
    triangle {Octa_B, Octa_D, Octa_E}
    triangle {Octa_B, Octa_D, Octa_F}
  }
}
#declare Octahedron_Faces = object { Octahedron }
#macro Octahedron_Vertices ( R )
  object {
    union {
      sphere { Octa_A, R }
      sphere { Octa_B, R }
      sphere { Octa_C, R }
      sphere { Octa_D, R }
      sphere { Octa_E, R }
      sphere { Octa_F, R }
    }
  }
#end
#macro Octahedron_Edges ( R )
  object {
    union {
      cylinder { Octa_A, Octa_C, R }
      cylinder { Octa_A, Octa_D, R }
      cylinder { Octa_A, Octa_E, R }
      cylinder { Octa_A, Octa_F, R }
      cylinder { Octa_B, Octa_C, R }
      cylinder { Octa_B, Octa_D, R }
      cylinder { Octa_B, Octa_E, R }
      cylinder { Octa_B, Octa_F, R }
      cylinder { Octa_C, Octa_E, R }
      cylinder { Octa_C, Octa_F, R }
      cylinder { Octa_D, Octa_E, R }
      cylinder { Octa_D, Octa_F, R }
    }
  }
#end

#declare Platonic_P = (sqrt(5)+1)/2;
#declare Platonic_I = (sqrt(5)-1)/2;

#declare Dodeca_First = < 0,  Platonic_P,  Platonic_I>;
#declare Dodeca_Len = vlength ( Dodeca_First );
#declare Dodeca_A = < 0,           Platonic_P,  Platonic_I>/Dodeca_Len;
#declare Dodeca_B = < 0,           Platonic_P, -Platonic_I>/Dodeca_Len;
#declare Dodeca_C = < 0,          -Platonic_P,  Platonic_I>/Dodeca_Len;
#declare Dodeca_D = < 0,          -Platonic_P, -Platonic_I>/Dodeca_Len;
#declare Dodeca_E = < Platonic_I,  0,           Platonic_P>/Dodeca_Len;
#declare Dodeca_F = < Platonic_I,  0,          -Platonic_P>/Dodeca_Len;
#declare Dodeca_G = <-Platonic_I,  0,           Platonic_P>/Dodeca_Len;
#declare Dodeca_H = <-Platonic_I,  0,          -Platonic_P>/Dodeca_Len;
#declare Dodeca_I = < Platonic_P,  Platonic_I,  0>/Dodeca_Len;
#declare Dodeca_J = < Platonic_P, -Platonic_I,  0>/Dodeca_Len;
#declare Dodeca_K = <-Platonic_P,  Platonic_I,  0>/Dodeca_Len;
#declare Dodeca_L = <-Platonic_P, -Platonic_I,  0>/Dodeca_Len;
#declare Dodeca_M = < 1,           1,           1>/Dodeca_Len;
#declare Dodeca_N = < 1,           1,          -1>/Dodeca_Len;
#declare Dodeca_O = < 1,          -1,           1>/Dodeca_Len;
#declare Dodeca_P = < 1,          -1,          -1>/Dodeca_Len;
#declare Dodeca_Q = <-1,           1,           1>/Dodeca_Len;
#declare Dodeca_R = <-1,           1,          -1>/Dodeca_Len;
#declare Dodeca_S = <-1,          -1,           1>/Dodeca_Len;
#declare Dodeca_T = <-1,          -1,          -1>/Dodeca_Len;
#declare Dodecahedron = object {
  union {
    Pentagon(Dodeca_A,Dodeca_B,Dodeca_R,Dodeca_K,Dodeca_Q)
    Pentagon(Dodeca_A,Dodeca_M,Dodeca_E,Dodeca_G,Dodeca_Q)
    Pentagon(Dodeca_A,Dodeca_M,Dodeca_I,Dodeca_N,Dodeca_B)
    Pentagon(Dodeca_B,Dodeca_N,Dodeca_F,Dodeca_H,Dodeca_R)
    Pentagon(Dodeca_C,Dodeca_D,Dodeca_T,Dodeca_L,Dodeca_S)
    Pentagon(Dodeca_C,Dodeca_O,Dodeca_J,Dodeca_P,Dodeca_D)
    Pentagon(Dodeca_C,Dodeca_S,Dodeca_G,Dodeca_E,Dodeca_O)
    Pentagon(Dodeca_D,Dodeca_T,Dodeca_H,Dodeca_F,Dodeca_P)
    Pentagon(Dodeca_E,Dodeca_M,Dodeca_I,Dodeca_J,Dodeca_O)
    Pentagon(Dodeca_F,Dodeca_N,Dodeca_I,Dodeca_J,Dodeca_P)
    Pentagon(Dodeca_G,Dodeca_S,Dodeca_L,Dodeca_K,Dodeca_Q)
    Pentagon(Dodeca_H,Dodeca_T,Dodeca_L,Dodeca_K,Dodeca_R)
  }
}
#declare Dodecahedron_Faces = object { Dodecahedron }
#macro Dodecahedron_Vertices ( R )
  object {
    union {
      sphere { Dodeca_A, R }
      sphere { Dodeca_B, R }
      sphere { Dodeca_C, R }
      sphere { Dodeca_D, R }
      sphere { Dodeca_E, R }
      sphere { Dodeca_F, R }
      sphere { Dodeca_G, R }
      sphere { Dodeca_H, R }
      sphere { Dodeca_I, R }
      sphere { Dodeca_J, R }
      sphere { Dodeca_K, R }
      sphere { Dodeca_L, R }
      sphere { Dodeca_M, R }
      sphere { Dodeca_N, R }
      sphere { Dodeca_O, R }
      sphere { Dodeca_P, R }
      sphere { Dodeca_Q, R }
      sphere { Dodeca_R, R }
      sphere { Dodeca_S, R }
      sphere { Dodeca_T, R }
    }
  }
#end
#macro Dodecahedron_Edges ( R )
  object {
    union {
      cylinder { Dodeca_A, Dodeca_B, R }
      cylinder { Dodeca_A, Dodeca_M, R }
      cylinder { Dodeca_A, Dodeca_Q, R }
      cylinder { Dodeca_B, Dodeca_N, R }
      cylinder { Dodeca_B, Dodeca_R, R }
      cylinder { Dodeca_C, Dodeca_D, R }
      cylinder { Dodeca_C, Dodeca_O, R }
      cylinder { Dodeca_C, Dodeca_S, R }
      cylinder { Dodeca_D, Dodeca_P, R }
      cylinder { Dodeca_D, Dodeca_T, R }
      cylinder { Dodeca_E, Dodeca_G, R }
      cylinder { Dodeca_E, Dodeca_M, R }
      cylinder { Dodeca_E, Dodeca_O, R }
      cylinder { Dodeca_F, Dodeca_H, R }
      cylinder { Dodeca_F, Dodeca_N, R }
      cylinder { Dodeca_F, Dodeca_P, R }
      cylinder { Dodeca_G, Dodeca_Q, R }
      cylinder { Dodeca_G, Dodeca_S, R }
      cylinder { Dodeca_H, Dodeca_R, R }
      cylinder { Dodeca_H, Dodeca_T, R }
      cylinder { Dodeca_I, Dodeca_J, R }
      cylinder { Dodeca_I, Dodeca_M, R }
      cylinder { Dodeca_I, Dodeca_N, R }
      cylinder { Dodeca_J, Dodeca_O, R }
      cylinder { Dodeca_J, Dodeca_P, R }
      cylinder { Dodeca_K, Dodeca_L, R }
      cylinder { Dodeca_K, Dodeca_Q, R }
      cylinder { Dodeca_K, Dodeca_R, R }
      cylinder { Dodeca_L, Dodeca_S, R }
      cylinder { Dodeca_L, Dodeca_T, R }
    }
  }
#end

#declare Icosa_First = < 0, 1, Platonic_P>;
#declare Icosa_Len = vlength ( Icosa_First );
#declare Icosa_A = < 0,           1,           Platonic_P>/Icosa_Len;
#declare Icosa_B = < 0,           1,          -Platonic_P>/Icosa_Len;
#declare Icosa_C = < 0,          -1,           Platonic_P>/Icosa_Len;
#declare Icosa_D = < 0,          -1,          -Platonic_P>/Icosa_Len;
#declare Icosa_E = < 1,           Platonic_P,  0>/Icosa_Len;
#declare Icosa_F = < 1,          -Platonic_P,  0>/Icosa_Len;
#declare Icosa_G = <-1,           Platonic_P,  0>/Icosa_Len;
#declare Icosa_H = <-1,          -Platonic_P,  0>/Icosa_Len;
#declare Icosa_I = < Platonic_P,  0,           1>/Icosa_Len;
#declare Icosa_J = < Platonic_P,  0,          -1>/Icosa_Len;
#declare Icosa_K = <-Platonic_P,  0,           1>/Icosa_Len;
#declare Icosa_L = <-Platonic_P,  0,          -1>/Icosa_Len;
#declare Icosahedron = object {
  mesh {
    triangle{Icosa_A,Icosa_C,Icosa_I}
    triangle{Icosa_A,Icosa_C,Icosa_K}
    triangle{Icosa_A,Icosa_E,Icosa_G}
    triangle{Icosa_A,Icosa_E,Icosa_I}
    triangle{Icosa_A,Icosa_G,Icosa_K}
    triangle{Icosa_B,Icosa_D,Icosa_J}
    triangle{Icosa_B,Icosa_D,Icosa_L}
    triangle{Icosa_B,Icosa_E,Icosa_G}
    triangle{Icosa_B,Icosa_E,Icosa_J}
    triangle{Icosa_B,Icosa_G,Icosa_L}
    triangle{Icosa_C,Icosa_F,Icosa_H}
    triangle{Icosa_C,Icosa_F,Icosa_I}
    triangle{Icosa_C,Icosa_H,Icosa_K}
    triangle{Icosa_D,Icosa_F,Icosa_H}
    triangle{Icosa_D,Icosa_F,Icosa_J}
    triangle{Icosa_D,Icosa_H,Icosa_L}
    triangle{Icosa_E,Icosa_I,Icosa_J}
    triangle{Icosa_F,Icosa_I,Icosa_J}
    triangle{Icosa_G,Icosa_K,Icosa_L}
    triangle{Icosa_H,Icosa_K,Icosa_L}
  }
}
#declare Icosahedron_Faces = object { Icosahedron }
#macro Icosahedron_Vertices ( R )
  object {
    union {
      sphere { Icosa_A, R }
      sphere { Icosa_B, R }
      sphere { Icosa_C, R }
      sphere { Icosa_D, R }
      sphere { Icosa_E, R }
      sphere { Icosa_F, R }
      sphere { Icosa_G, R }
      sphere { Icosa_H, R }
      sphere { Icosa_I, R }
      sphere { Icosa_J, R }
      sphere { Icosa_K, R }
      sphere { Icosa_L, R }
    }
  }
#end
#macro Icosahedron_Edges ( R )
  object {
    union {
      cylinder { Icosa_A, Icosa_C, R }
      cylinder { Icosa_A, Icosa_E, R }
      cylinder { Icosa_A, Icosa_G, R }
      cylinder { Icosa_A, Icosa_I, R }
      cylinder { Icosa_A, Icosa_K, R }
      cylinder { Icosa_B, Icosa_D, R }
      cylinder { Icosa_B, Icosa_E, R }
      cylinder { Icosa_B, Icosa_G, R }
      cylinder { Icosa_B, Icosa_J, R }
      cylinder { Icosa_B, Icosa_L, R }
      cylinder { Icosa_C, Icosa_F, R }
      cylinder { Icosa_C, Icosa_H, R }
      cylinder { Icosa_C, Icosa_I, R }
      cylinder { Icosa_C, Icosa_K, R }
      cylinder { Icosa_D, Icosa_F, R }
      cylinder { Icosa_D, Icosa_H, R }
      cylinder { Icosa_D, Icosa_J, R }
      cylinder { Icosa_D, Icosa_L, R }
      cylinder { Icosa_E, Icosa_G, R }
      cylinder { Icosa_E, Icosa_I, R }
      cylinder { Icosa_E, Icosa_J, R }
      cylinder { Icosa_F, Icosa_H, R }
      cylinder { Icosa_F, Icosa_I, R }
      cylinder { Icosa_F, Icosa_J, R }
      cylinder { Icosa_G, Icosa_K, R }
      cylinder { Icosa_G, Icosa_L, R }
      cylinder { Icosa_H, Icosa_K, R }
      cylinder { Icosa_H, Icosa_L, R }
      cylinder { Icosa_I, Icosa_J, R }
      cylinder { Icosa_K, Icosa_L, R }
    }
  }
#end

#declare Platonic_Bounding_Sphere = sphere {
  <0, 0, 0>,
  1
}

#macro Platonic_Center_Sphere ( R )
  object {
    sphere {
      <0, 0, 0>,
      R
    }
  }
#end

-----


Post a reply to this message

From: Deaken
Subject: Re: Platonic solids (take two)
Date: 18 Jan 2002 07:17:33
Message: <3C48127F.29FA2F3B@sw-tech.com>
Deaken wrote:
> 
> // Bugs: I do not provide "Hexahedron" as a synonym for "Cube".
> //       I do not provide the vectors by which you can scale and rotate
> //       the polyhedra to get them to rest flat on the Y plane.
> //       These comments are WAY too verbose.

Of course I meant "translate and rotate".

Deaken


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.