Skip to content

Instantly share code, notes, and snippets.

@nmmmnu
Created September 20, 2018 11:37
Show Gist options
  • Save nmmmnu/e51bdd447e0cafa1bd37fb41d78fcd5c to your computer and use it in GitHub Desktop.
Save nmmmnu/e51bdd447e0cafa1bd37fb41d78fcd5c to your computer and use it in GitHub Desktop.
Platonic Solids
#define fip0 1.618
#define fim0 -1.618
#define fip1 0.618
#define fim1 -0.618
#define sqrtp1 0.7071
#define sqrtm1 -0.7071
rule tetrahedron {
{ x +1 y 0 z sqrtm1 } box
{ x -1 y 0 z sqrtm1 } box
{ x 0 y +1 z sqrtp1 } box
{ x 0 y -1 z sqrtp1 } box
}
rule cube {
{ x +1 y +1 z +1 } box
{ x +1 y +1 z -1 } box
{ x +1 y -1 z +1 } box
{ x +1 y -1 z -1 } box
{ x -1 y +1 z +1 } box
{ x -1 y +1 z -1 } box
{ x -1 y -1 z +1 } box
{ x -1 y -1 z -1 } box
}
rule octahedron {
{ x +1 y 0 z 0 } box
{ x -1 y 0 z 0 } box
{ x 0 y +1 z 0 } box
{ x 0 y -1 z 0 } box
{ x 0 y 0 z +1 } box
{ x 0 y 0 z -1 } box
}
rule dodecahedron {
{ x +1 y +1 z +1 } box
{ x +1 y +1 z -1 } box
{ x +1 y -1 z +1 } box
{ x +1 y -1 z -1 } box
{ x -1 y +1 z +1 } box
{ x -1 y +1 z -1 } box
{ x -1 y -1 z +1 } box
{ x -1 y -1 z -1 } box
{ x 0 y fip0 z fip1 } box
{ x 0 y fip0 z fim1 } box
{ x 0 y fim0 z fip1 } box
{ x 0 y fim0 z fim1 } box
{ x fip1 y 0 z fip0 } box
{ x fim1 y 0 z fip0 } box
{ x fip1 y 0 z fim0 } box
{ x fim1 y 0 z fim0 } box
{ x fip0 y fip1 z 0 } box
{ x fip0 y fim1 z 0 } box
{ x fim0 y fip1 z 0 } box
{ x fim0 y fim1 z 0 } box
}
rule icosahedron {
{ x 0 y +1 z fip0 } box
{ x 0 y +1 z fim0 } box
{ x 0 y -1 z fip0 } box
{ x 0 y -1 z fim0 } box
{ x +1 y fip0 z 0 } box
{ x +1 y fim0 z 0 } box
{ x -1 y fip0 z 0 } box
{ x -1 y fim0 z 0 } box
{ x fip0 y 0 z +1 } box
{ x fim0 y 0 z +1 } box
{ x fip0 y 0 z -1 } box
{ x fim0 y 0 z -1 } box
}
{ x 0 } tetrahedron
{ x 5 } cube
{ x 10 } octahedron
{ x 15 } dodecahedron
{ x 20 } icosahedron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment