From: CDO@IB.RL.AC.UK (C D Osland)
Newsgroups: comp.graphics.visualization
Subject: Re: Wanted: Geodesic Dome co-ordinates,geom's
Date: 20 Nov 92 14:19:51 GMT

On 19 Nov 92 19:13:10 GMT <craig@EDU.UCLA.LONI.HYPERION> said:
>
>	The subject line pretty much says it; Has anyone a representation
>	of a geodesic dome - or , even better, a means of generating
>	the vertex co-ordinates ??
>
>	thanks
>
>		Craig
>
>		craig@hyperion.loni.ucla.edu
>

Some months ago there was code for Platonic solids and a football
circulated.  This may be useful, in that it's close to a geodesic
dome.  I attach the code in the form that it came from the authors.
It works!

Chris Osland
Rutherford Appleton Laboratory, UK
----------------------------------
======================================================================== 342
Received: from UKACRL by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 1836; Thu, 21
 May 92 15:27:02 BST
Received:
           from UKACRL by UKACRL.BITNET (Mailer R2.07) with BSMTP id 5427; Thu,
               21 May 92 15:26:46 BST
Received:      from psi.rutgers.edu by ib.rl.ac.uk (IBM VM SMTP V2R1) with TCP;
               Thu, 21 May 92 15:26:34 BS
Received:      from RUTGERS.EDU by psi.rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
                id AA14133; Thu, 21 May 92 10:24:54 ED
Received:      by rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
                id AA08528; Thu, 21 May 92 10:24:50 ED
Message-Id:    <9205211424.AA08528@rutgers.edu>
Reply-To:      comp-graphics-research@EDU.RUTGERS.VIZLAB
From:          wilson@EDU.UCF.CS.OSCEOLA
Subject:       (NFF) Platonic Solid Generator: platonics.c
Date:          21 May 92 13:14:21 GMT
Followup-To:   comp.graphics
X-Submissions-To: graphics@scri1.scri.fsu.edu
X-Administrivia-To: graphics-request@scri1.scri.fsu.edu
Apparently-To: comp-graphics-research-dist@vizlab.rutgers.edu

/*
Platonic Solid Generator by Tom Wilson, 1992

This program generates the seven platonic solids: tetra, cube, octahedron,
cubeoctahedron, icosahedron, dodecahedron, and icosidodecahedron. These may be
scaled and/or translated (no rotation). After compiling the program, invoke it
with any of the following parameters:

-h  generates an NFF header (viewpoint, etc.) which should be hand edited
-C  generates polygons for a cube
-c  generates polygons for a cubeoctahedron
-D  generates polygons for a dodecahedron
-I  generates polygons for an icosahedron
-i  generates polygons for an icosidodecahedron
-O  generates polygons for an octahedron
-T  generates polygons for a tetrahedron
-s# scales any objects that follow it by #
-x# translates any objects that follow it by # in the x direction
-y# translates any objects that follow it by # in the y direction
-z# translates any objects that follow it by # in the z direction

Each object is normally centered about 0,0,0 and exists within a box with
corners -1.61803,-1.61803,-1.61803 and 1.61803,1.61803,1.61803 (you can always
scale it to something else). Each object consists of 3-, 4-, or 5-sided
polygons. Each object is preceded by a comment defining where the object begins
and another comment with a surface characterics line that should be hand
edited. Here's an example which generates a header, and one of each object in
the form of an H (the program when compiled is called "platonics"):

platonics -h -x-3 -y3 -C -x3 -c -x-3 -y0 -T -x0 -D -x3 -O -x-3 -y-3 -I -x3 -i

Use "from 0 0 10" and lights at (10,10,10), (-10,10,10), (10,-10,10), and
(-10,-10,10) with the above example.
*/

#include <stdio.h>

typedef float FLT;

FLT scale = 1.0, tx = 0.0, ty = 0.0, tz = 0.0;

typedef struct pointrec
          {FLT x, y, z;
          } POINT;

POINT tetra[4] = /* tetrahedron */
       {{1.0, 1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0},
        {-1.0, -1.0, 1.0}};
POINT cube[8] = /* cube */
       {{1.0, 1.0, 1.0}, {1.0, 1.0, -1.0}, {1.0, -1.0, -1.0}, {1.0, -1.0, 1.0},
        {-1.0, -1.0, 1.0}, {-1.0, 1.0, 1.0}, {-1.0, 1.0, -1.0},
        {-1.0, -1.0, -1.0}};
POINT octa[6] = /* octahedron */
       {{1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0},
        {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}};
POINT cubeocta[12] = /* cubeoctahedron */
       {{0.0, 1.0, 1.0}, {0.0, -1.0, 1.0}, {0.0, -1.0, -1.0}, {0.0, 1.0, -1.0},
        {1.0, 0.0, 1.0}, {-1.0, 0.0, 1.0}, {-1.0, 0.0, -1.0}, {1.0, 0.0, -1.0},
        {1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, {-1.0, -1.0, 0.0}, {1.0, -1.0, 0.0}};
POINT icosa[12] = /* icosahedron */
       {{0.0, 1.61803, 1.0}, {0.0, -1.61803, 1.0}, {0.0, 1.61803, -1.0},
        {0.0, -1.61803, -1.0}, {1.0, 0.0, 1.61803}, {-1.0, 0.0, 1.61803},
        {1.0, 0.0, -1.61803}, {-1.0, 0.0, -1.61803}, {1.61803, 1.0, 0.0},
        {-1.61803, 1.0, 0.0}, {1.61803, -1.0, 0.0}, {-1.61803, -1.0, 0.0}};
POINT dodeca[20] = /* dodecahedron */
       {{0.0, 0.618034, 1.61803}, {0.0, -0.618034, 1.61803},
        {0.0, -0.618034, -1.61803}, {0.0, 0.618034, -1.61803},
        {1.61803, 0.0, 0.618034}, {-1.61803, 0.0, 0.618034},
        {-1.61803, 0.0, -0.618034}, {1.61803, 0.0, -0.618034},
        {0.618034, 1.61803, 0.0}, {-0.618034, 1.61803, 0.0},
        {-0.618034, -1.61803, 0.0}, {0.618034, -1.61803, 0.0}, {1.0, 1.0, 1.0},
        {-1.0, 1.0, 1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0},
        {1.0, -1.0, -1.0}, {1.0, 1.0, -1.0}, {-1.0, 1.0, -1.0},
        {-1.0, -1.0, -1.0}};
POINT icosidodeca[30] = /* icosidodecahedron */
       {{2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0},
        {0.0, 0.0, 2.0}, {0.0, 0.0, -2.0},
        {1.61803, 0.618034, 1.0}, {1.61803, 0.618034, -1.0},
        {1.61803, -0.618034, 1.0}, {1.61803, -0.618034, -1.0},
        {-1.61803, 0.618034, 1.0}, {-1.61803, 0.618034, -1.0},
        {-1.61803, -0.618034, 1.0}, {-1.61803, -0.618034, -1.0},
        {1.0, 1.61803, 0.618034}, {1.0, 1.61803, -0.618034},
        {1.0, -1.61803, 0.618034}, {1.0, -1.61803, -0.618034},
        {-1.0, 1.61803, 0.618034}, {-1.0, 1.61803, -0.618034},
        {-1.0, -1.61803, 0.618034}, {-1.0, -1.61803, -0.618034},
        {0.618034, 1.0, 1.61803}, {0.618034, 1.0, -1.61803},
        {0.618034, -1.0, 1.61803}, {0.618034, -1.0, -1.61803},
        {-0.618034, 1.0, 1.61803}, {-0.618034, 1.0, -1.61803},
        {-0.618034, -1.0, 1.61803}, {-0.618034, -1.0, -1.61803}};

main(argc,argv)
  int argc;
  char *argv[];
{char *s;
 int cnt;

 cnt = 1;
 while (--argc > 0 && argv[cnt][0] == '-')
  {s = argv[cnt]+1;
   switch (*s)
    {case 'C':
       makecube();
       break;
     case 'c':
       makecubeocta();
       break;
     case 'D':
       makedodeca();
       break;
     case 'h':
       makeheader();
       break;
     case 'I':
       makeicosa();
       break;
     case 'i':
       makeicosidodeca();
       break;
     case 'O':
       makeocta();
       break;
     case 's':
       sscanf(argv[cnt]+2,"%f",&scale);
       break;
     case 'T':
       maketetra();
       break;
     case 'x':
       sscanf(argv[cnt]+2,"%f",&tx);
       break;
     case 'y':
       sscanf(argv[cnt]+2,"%f",&ty);
       break;
     case 'z':
       sscanf(argv[cnt]+2,"%f",&tz);
       break;
     default: printf("argv[%d]=%s\n",cnt,argv[cnt]);
       break;
    }
   cnt++;
  }
}

makeheader()
{printf("v\nfrom 0 0 1\nat 0 0 0\nup 0 1 0\nangle 45\nhither 1\n");
 printf("resolution 512 512\nb 0 0 0\nl 0 1 1\n");
}

maketetra()
{printf("#tetrahedron: 4 polygons\n");
 printf("#f 0 0 0 0 0 0 0 0\n");
 tri(tetra,0,1,2);
 tri(tetra,0,1,3);
 tri(tetra,0,2,3);
 tri(tetra,1,2,3);
}

makecube()
{printf("#cube: 6 polygons\n");
 printf("#f 0 0 0 0 0 0 0 0\n");
 quad(cube,0,1,2,3);
 quad(cube,0,3,4,5);
 quad(cube,0,1,6,5);
 quad(cube,1,2,7,6);
 quad(cube,2,3,4,7);
 quad(cube,4,5,6,7);
}

makeocta()
{printf("#octahedron: 8 polygons\n");
 printf("#f 0 0 0 0 0 0 0 0\n");
 tri(octa,0,2,4);
 tri(octa,0,2,5);
 tri(octa,0,3,4);
 tri(octa,0,3,5);
 tri(octa,1,2,4);
 tri(octa,1,2,5);
 tri(octa,1,3,4);
 tri(octa,1,3,5);
}

makecubeocta()
{printf("#cubeoctahedron: 14 polygons\n");
 printf("#f 0 0 0 0 0 0 0 0\n");
 tri(cubeocta,0,4,8);
 tri(cubeocta,0,5,9);
 tri(cubeocta,1,4,11);
 tri(cubeocta,1,5,10);
 tri(cubeocta,2,6,10);
 tri(cubeocta,2,7,11);
 tri(cubeocta,3,6,9);
 tri(cubeocta,3,7,8);
 quad(cubeocta,0,8,3,9);
 quad(cubeocta,0,5,1,4);
 quad(cubeocta,1,11,2,10);
 quad(cubeocta,2,7,3,6);
 quad(cubeocta,4,11,7,8);
 quad(cubeocta,5,10,6,9);
}

makeicosa()
{printf("#icosahedron: 20 polygons\n");
 printf("#f 0 0 0 0 0 0 0 0\n");
 tri(icosa,0,4,5);
 tri(icosa,0,4,8);
 tri(icosa,4,8,10);
 tri(icosa,1,4,10);
 tri(icosa,1,4,5);
 tri(icosa,1,5,11);
 tri(icosa,5,9,11);
 tri(icosa,0,5,9);
 tri(icosa,0,2,9);
 tri(icosa,0,2,8);
 tri(icosa,1,3,11);
 tri(icosa,1,3,10);
 tri(icosa,2,6,7);
 tri(icosa,2,6,8);
 tri(icosa,6,8,10);
 tri(icosa,3,6,10);
 tri(icosa,3,6,7);
 tri(icosa,3,7,11);
 tri(icosa,7,9,11);
 tri(icosa,2,7,9);
}

makedodeca()
{printf("#dodecahedron: 12 polygons\n");
 printf("#f 0 0 0 0 0 0 0 0\n");
 pent(dodeca,0,1,15,4,12);
 pent(dodeca,0,12,8,9,13);
 pent(dodeca,0,13,5,14,1);
 pent(dodeca,1,14,10,11,15);
 pent(dodeca,2,3,17,7,16);
 pent(dodeca,2,16,11,10,19);
 pent(dodeca,2,19,6,18,3);
 pent(dodeca,3,17,8,9,18);
 pent(dodeca,4,7,16,11,15);
 pent(dodeca,4,7,17,8,12);
 pent(dodeca,5,6,18,9,13);
 pent(dodeca,5,6,19,10,14);
}

makeicosidodeca()
{printf("#icosidodecahedron: 32 polygons\n");
 printf("#f 0 0 0 0 0 0 0 0\n");
 pent(icosidodeca,0,6,14,15,7);
 pent(icosidodeca,0,8,16,17,9);
 pent(icosidodeca,1,10,18,19,11);
 pent(icosidodeca,1,12,20,21,13);
 pent(icosidodeca,2,14,22,26,18);
 pent(icosidodeca,2,15,23,27,19);
 pent(icosidodeca,3,16,24,28,20);
 pent(icosidodeca,3,17,25,29,21);
 pent(icosidodeca,4,22,6,8,24);
 pent(icosidodeca,4,26,10,12,28);
 pent(icosidodeca,5,23,7,9,25);
 pent(icosidodeca,5,27,11,13,29);
 tri(icosidodeca,0,6,8);
 tri(icosidodeca,0,7,9);
 tri(icosidodeca,1,10,12);
 tri(icosidodeca,1,11,13);
 tri(icosidodeca,2,14,15);
 tri(icosidodeca,2,18,19);
 tri(icosidodeca,3,16,17);
 tri(icosidodeca,3,20,21);
 tri(icosidodeca,4,22,26);
 tri(icosidodeca,4,24,28);
 tri(icosidodeca,5,23,27);
 tri(icosidodeca,5,25,29);
 tri(icosidodeca,6,14,22);
 tri(icosidodeca,7,15,23);
 tri(icosidodeca,8,16,24);
 tri(icosidodeca,9,17,25);
 tri(icosidodeca,10,18,26);
 tri(icosidodeca,11,19,27);
 tri(icosidodeca,12,20,28);
 tri(icosidodeca,13,21,29);
}

tri(a,p1,p2,p3)
  POINT *a;
  int p1, p2, p3;
{printf("p 3\n");
 prtpt(a,p1);
 prtpt(a,p2);
 prtpt(a,p3);
}

quad(a,p1,p2,p3,p4)
  POINT *a;
  int p1, p2, p3, p4;
{printf("p 4\n");
 prtpt(a,p1);
 prtpt(a,p2);
 prtpt(a,p3);
 prtpt(a,p4);
}

pent(a,p1,p2,p3,p4,p5)
  POINT *a;
  int p1, p2, p3, p4, p5;
{printf("p 5\n");
 prtpt(a,p1);
 prtpt(a,p2);
 prtpt(a,p3);
 prtpt(a,p4);
 prtpt(a,p5);
}

prtpt(a,p)
  POINT *a;
  int p;
{printf("%g %g %g\n",scale*a[p].x+tx,scale*a[p].y+ty,scale*a[p].z+tz);
}

--
Moderated by SCRI Vis <>           Submissions to: graphics@scri1.scri.fsu.edu
Guy, John R. Murray   <> Administrivia to: graphics-request@scri1.scri.fsu.edu

======================================================================== 167
Received: from UKACRL by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 5141; Thu, 21
 May 92 19:25:13 BST
Received:
           from UKACRL by UKACRL.BITNET (Mailer R2.07) with BSMTP id 2429; Thu,
               21 May 92 19:24:40 BST
Received:      from psi.rutgers.edu by ib.rl.ac.uk (IBM VM SMTP V2R1) with TCP;
               Thu, 21 May 92 19:24:33 BS
Received:      from RUTGERS.EDU by psi.rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
                id AA21051; Thu, 21 May 92 14:24:09 ED
Received:      by rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
                id AA12619; Thu, 21 May 92 14:24:07 ED
Message-Id:    <9205211824.AA12619@rutgers.edu>
Reply-To:      comp-graphics-research@EDU.RUTGERS.VIZLAB
From:          wilson@EDU.UCF.CS.OSCEOLA
Subject:       (NFF) Soccerball Platonic Solid Generator: soccerball.c
Date:          21 May 92 17:14:21 GMT
Followup-To:   comp.graphics
X-Submissions-To: graphics@scri1.scri.fsu.edu
X-Administrivia-To: graphics-request@scri1.scri.fsu.edu
Apparently-To: comp-graphics-research-dist@vizlab.rutgers.edu

/*
Soccerball Platonic Solid Generator by Tom Wilson, 1992

Believe it or not the points needed to generate a soccerball can be derived
from the points on an icosahedron. Unfortunately, this generates flat panels
whereas a real soccerball has curved surfaces when inflated. Oh well, I used
smooth shading (pp in NFF) to help it look better. It looks realistic except
for the edges which are obviously planar. A soccerball is not really a
platonic solid (but neither is a teapot 8-). No scaling or translating is
allowed.

*/

#include <stdio.h>
#include <math.h>

double dot();

typedef struct pointrec
          {double x, y, z;
          } POINT;

typedef struct ptrec
         {POINT p[5];
          int n;
         } PENTPOINT;

POINT icosahedron[12] =
       {{0.0, 1.61803, 1.0}, {0.0, -1.61803, 1.0}, {0.0, 1.61803, -1.0},
        {0.0, -1.61803, -1.0}, {1.0, 0.0, 1.61803}, {-1.0, 0.0, 1.61803},
        {1.0, 0.0, -1.61803}, {-1.0, 0.0, -1.61803}, {1.61803, 1.0, 0.0},
        {-1.61803, 1.0, 0.0}, {1.61803, -1.0, 0.0}, {-1.61803, -1.0, 0.0}};
PENTPOINT pentagons[12];

main()
{int t, w;
 double l;

 printf("v\nfrom 3 8 8\nat 0 0 0\nup 0 1 0\nangle 45\nhither 1\n");
 printf("resolution 512 512\nb 0 1 0\nl 10 10 5\nl -10 10 5\nl 10 10 -5\nl -10
 -10 5\n");
 printf("f 1 1 1 1 0 0 0 0\n");
 printf("#32 polygons\n");
 hexagon(0,8,4);
 hexagon(0,4,5);
 hexagon(0,5,9);
 hexagon(0,9,2);
 hexagon(0,2,8);
 hexagon(1,4,10);
 hexagon(1,5,4);
 hexagon(1,11,5);
 hexagon(1,3,11);
 hexagon(1,10,3);
 hexagon(2,6,8);
 hexagon(2,7,6);
 hexagon(2,9,7);
 hexagon(4,8,10);
 hexagon(5,11,9);
 hexagon(6,10,8);
 hexagon(3,10,6);
 hexagon(3,6,7);
 hexagon(3,7,11);
 hexagon(7,9,11);
 printf("f 0 0 0 1 0 0 0 0\n");
 for (t = 0; t < 12; t++)
  {fixpts(t);
   printf("pp 5\n");
   for (w = 0; w < 5; w++)
    {printf("%g %g %g ",pentagons[t].p[w].x,pentagons[t].p[w].y,
            pentagons[t].p[w].z);
     l = sqrt(pentagons[t].p[w].x*pentagons[t].p[w].x +
              pentagons[t].p[w].y*pentagons[t].p[w].y +
              pentagons[t].p[w].z*pentagons[t].p[w].z);
     printf("%g %g %g\n",pentagons[t].p[w].x/l,pentagons[t].p[w].y/l,
            pentagons[t].p[w].z/l);
    }
  }
}

arccos(a)
  double a;
{return (int) (acos(a)*180.0/3.1415926);
}

fixpts(t)
  int t;
{POINT pt;
 int w, v;

 for (w = 0; w < 3; w++)
   for (v = w+1; v < 5; v++)
     if (arccos(dot(pentagons[t].p[w],pentagons[t].p[v])) == 23)
       if (v == w+1)
         break;
       else {pt = pentagons[t].p[w+1];
             pentagons[t].p[w+1] = pentagons[t].p[v];
             pentagons[t].p[v] = pt;
             break;
            }
}

double dot(p1,p2)
  POINT p1, p2;
{double x, y, z, l1, l2;

 l1 = sqrt(p1.x*p1.x+p1.y*p1.y+p1.z*p1.z);
 l2 = sqrt(p2.x*p2.x+p2.y*p2.y+p2.z*p2.z);
 return (p1.x*p2.x + p1.y*p2.y + p1.z*p2.z)/(l1*l2);
}

hexagon(p1,p2,p3)
  int p1, p2, p3;
{printf("pp 6\n");
 make2pts(p1,p2);
 make2pts(p2,p3);
 make2pts(p3,p1);
}

make2pts(p1,p2)
  int p1, p2;
{POINT pa, pb;
 double l;
 int t;

 pa.x = icosahedron[p2].x + 2.0/3.0*(icosahedron[p1].x-icosahedron[p2].x);
 pa.y = icosahedron[p2].y + 2.0/3.0*(icosahedron[p1].y-icosahedron[p2].y);
 pa.z = icosahedron[p2].z + 2.0/3.0*(icosahedron[p1].z-icosahedron[p2].z);
 pb.x = icosahedron[p2].x + 1.0/3.0*(icosahedron[p1].x-icosahedron[p2].x);
 pb.y = icosahedron[p2].y + 1.0/3.0*(icosahedron[p1].y-icosahedron[p2].y);
 pb.z = icosahedron[p2].z + 1.0/3.0*(icosahedron[p1].z-icosahedron[p2].z);
 printf("%g %g %g ",pa.x,pa.y,pa.z);
 l = sqrt(pa.x*pa.x + pa.y*pa.y + pa.z*pa.z);
 printf("%g %g %g\n",pa.x/l,pa.y/l,pa.z/l);
 printf("%g %g %g ",pb.x,pb.y,pb.z);
 l = sqrt(pb.x*pb.x + pb.y*pb.y + pb.z*pb.z);
 printf("%g %g %g\n",pb.x/l,pb.y/l,pb.z/l);
 t = pentagons[p1].n++;
 pentagons[p1].p[t] = pa;
}

--
Moderated by SCRI Vis <>           Submissions to: graphics@scri1.scri.fsu.edu
Guy, John R. Murray   <> Administrivia to: graphics-request@scri1.scri.fsu.edu

======================================================================== 30
Received:
           from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 2679; Tue, 07
               May 91 18:49:22 BST
Via:           UK.AC.NSF;  7 MAY 91 18:49:19 BST
Received:      from vax.nsfnet-relay.ac.uk by sun2.nsfnet-relay.ac.uk
               with SMTP inbound id <12272-34@sun2.nsfnet-relay.ac.uk>;
               Tue, 7 May 1991 16:32:22 +01
Received:      from aramis.rutgers.edu by vax.NSFnet-Relay.AC.UK via NSFnet
               with SMTP id aa08913; 7 May 91 15:00 BS
Received:      by aramis.rutgers.edu (5.59/SMI4.0/RU1.4/3.08) id AA16046;
               Tue, 7 May 91 10:04:17 ED
Message-Id:    <9105071404.AA16046@aramis.rutgers.edu>
Reply-To:      comp-visualization@edu.rutgers.cs
From:          sulaiman@edu.umass.ecs
Subject:       Icosahedron help
Date:          6 May 91 13:02:31 GMT
Apparently-To: comp-visualization-dist@cs.rutgers.edu


 I need to find out how you would define the equations for all 12
planes of an icosahedron centered at 0,0,0. I am building a ray tracer
and i need to compute hit times (t in and t out) for several platonic solids
including .... an icosahedron ...

Thanx

P.S. I guess I need the equations for each plane. The vertices and edges
I think I already have figured out. oooops replace all reference to 'planes'
with 'faces'