home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / graphics / visualiz / 1792 < prev    next >
Encoding:
Text File  |  1992-11-20  |  17.3 KB  |  573 lines

  1. Path: sparky!uunet!dziuxsolim.rutgers.edu!psi.rutgers.edu!ib.rl.ac.uk!CDO
  2. From: CDO@IB.RL.AC.UK (C D Osland)
  3. Newsgroups: comp.graphics.visualization
  4. Subject: Re: Wanted: Geodesic Dome co-ordinates,geom's
  5. Message-ID: <9211201645.AA12813@psi.rutgers.edu>
  6. Date: 20 Nov 92 14:19:51 GMT
  7. References: <craig@EDU.UCLA.LONI.HYPERION>
  8. Sender: nobody@psi.rutgers.edu
  9. Lines: 562
  10.  
  11. On 19 Nov 92 19:13:10 GMT <craig@EDU.UCLA.LONI.HYPERION> said:
  12. >
  13. >    The subject line pretty much says it; Has anyone a representation
  14. >    of a geodesic dome - or , even better, a means of generating
  15. >    the vertex co-ordinates ??
  16. >
  17. >    thanks
  18. >
  19. >        Craig
  20. >
  21. >        craig@hyperion.loni.ucla.edu
  22. >
  23.  
  24. Some months ago there was code for Platonic solids and a football
  25. circulated.  This may be useful, in that it's close to a geodesic
  26. dome.  I attach the code in the form that it came from the authors.
  27. It works!
  28.  
  29. Chris Osland
  30. Rutherford Appleton Laboratory, UK
  31. ----------------------------------
  32. ======================================================================== 342
  33. Received: from UKACRL by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 1836; Thu, 21
  34.  May 92 15:27:02 BST
  35. Received:
  36.            from UKACRL by UKACRL.BITNET (Mailer R2.07) with BSMTP id 5427; Thu,
  37.                21 May 92 15:26:46 BST
  38. Received:      from psi.rutgers.edu by ib.rl.ac.uk (IBM VM SMTP V2R1) with TCP;
  39.                Thu, 21 May 92 15:26:34 BS
  40. Received:      from RUTGERS.EDU by psi.rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
  41.                 id AA14133; Thu, 21 May 92 10:24:54 ED
  42. Received:      by rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
  43.                 id AA08528; Thu, 21 May 92 10:24:50 ED
  44. Message-Id:    <9205211424.AA08528@rutgers.edu>
  45. Reply-To:      comp-graphics-research@EDU.RUTGERS.VIZLAB
  46. From:          wilson@EDU.UCF.CS.OSCEOLA
  47. Subject:       (NFF) Platonic Solid Generator: platonics.c
  48. Date:          21 May 92 13:14:21 GMT
  49. Sender:        news@EDU.FSU.SCRI.SUN13
  50. Followup-To:   comp.graphics
  51. Approved:      murray@vs6.scri.fsu.edu
  52. X-Submissions-To: graphics@scri1.scri.fsu.edu
  53. X-Administrivia-To: graphics-request@scri1.scri.fsu.edu
  54. Apparently-To: comp-graphics-research-dist@vizlab.rutgers.edu
  55.  
  56. /*
  57. Platonic Solid Generator by Tom Wilson, 1992
  58.  
  59. This program generates the seven platonic solids: tetra, cube, octahedron,
  60. cubeoctahedron, icosahedron, dodecahedron, and icosidodecahedron. These may be
  61. scaled and/or translated (no rotation). After compiling the program, invoke it
  62. with any of the following parameters:
  63.  
  64. -h  generates an NFF header (viewpoint, etc.) which should be hand edited
  65. -C  generates polygons for a cube
  66. -c  generates polygons for a cubeoctahedron
  67. -D  generates polygons for a dodecahedron
  68. -I  generates polygons for an icosahedron
  69. -i  generates polygons for an icosidodecahedron
  70. -O  generates polygons for an octahedron
  71. -T  generates polygons for a tetrahedron
  72. -s# scales any objects that follow it by #
  73. -x# translates any objects that follow it by # in the x direction
  74. -y# translates any objects that follow it by # in the y direction
  75. -z# translates any objects that follow it by # in the z direction
  76.  
  77. Each object is normally centered about 0,0,0 and exists within a box with
  78. corners -1.61803,-1.61803,-1.61803 and 1.61803,1.61803,1.61803 (you can always
  79. scale it to something else). Each object consists of 3-, 4-, or 5-sided
  80. polygons. Each object is preceded by a comment defining where the object begins
  81. and another comment with a surface characterics line that should be hand
  82. edited. Here's an example which generates a header, and one of each object in
  83. the form of an H (the program when compiled is called "platonics"):
  84.  
  85. platonics -h -x-3 -y3 -C -x3 -c -x-3 -y0 -T -x0 -D -x3 -O -x-3 -y-3 -I -x3 -i
  86.  
  87. Use "from 0 0 10" and lights at (10,10,10), (-10,10,10), (10,-10,10), and
  88. (-10,-10,10) with the above example.
  89. */
  90.  
  91. #include <stdio.h>
  92.  
  93. typedef float FLT;
  94.  
  95. FLT scale = 1.0, tx = 0.0, ty = 0.0, tz = 0.0;
  96.  
  97. typedef struct pointrec
  98.           {FLT x, y, z;
  99.           } POINT;
  100.  
  101. POINT tetra[4] = /* tetrahedron */
  102.        {{1.0, 1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0},
  103.         {-1.0, -1.0, 1.0}};
  104. POINT cube[8] = /* cube */
  105.        {{1.0, 1.0, 1.0}, {1.0, 1.0, -1.0}, {1.0, -1.0, -1.0}, {1.0, -1.0, 1.0},
  106.         {-1.0, -1.0, 1.0}, {-1.0, 1.0, 1.0}, {-1.0, 1.0, -1.0},
  107.         {-1.0, -1.0, -1.0}};
  108. POINT octa[6] = /* octahedron */
  109.        {{1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0},
  110.         {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}};
  111. POINT cubeocta[12] = /* cubeoctahedron */
  112.        {{0.0, 1.0, 1.0}, {0.0, -1.0, 1.0}, {0.0, -1.0, -1.0}, {0.0, 1.0, -1.0},
  113.         {1.0, 0.0, 1.0}, {-1.0, 0.0, 1.0}, {-1.0, 0.0, -1.0}, {1.0, 0.0, -1.0},
  114.         {1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, {-1.0, -1.0, 0.0}, {1.0, -1.0, 0.0}};
  115. POINT icosa[12] = /* icosahedron */
  116.        {{0.0, 1.61803, 1.0}, {0.0, -1.61803, 1.0}, {0.0, 1.61803, -1.0},
  117.         {0.0, -1.61803, -1.0}, {1.0, 0.0, 1.61803}, {-1.0, 0.0, 1.61803},
  118.         {1.0, 0.0, -1.61803}, {-1.0, 0.0, -1.61803}, {1.61803, 1.0, 0.0},
  119.         {-1.61803, 1.0, 0.0}, {1.61803, -1.0, 0.0}, {-1.61803, -1.0, 0.0}};
  120. POINT dodeca[20] = /* dodecahedron */
  121.        {{0.0, 0.618034, 1.61803}, {0.0, -0.618034, 1.61803},
  122.         {0.0, -0.618034, -1.61803}, {0.0, 0.618034, -1.61803},
  123.         {1.61803, 0.0, 0.618034}, {-1.61803, 0.0, 0.618034},
  124.         {-1.61803, 0.0, -0.618034}, {1.61803, 0.0, -0.618034},
  125.         {0.618034, 1.61803, 0.0}, {-0.618034, 1.61803, 0.0},
  126.         {-0.618034, -1.61803, 0.0}, {0.618034, -1.61803, 0.0}, {1.0, 1.0, 1.0},
  127.         {-1.0, 1.0, 1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0},
  128.         {1.0, -1.0, -1.0}, {1.0, 1.0, -1.0}, {-1.0, 1.0, -1.0},
  129.         {-1.0, -1.0, -1.0}};
  130. POINT icosidodeca[30] = /* icosidodecahedron */
  131.        {{2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0},
  132.         {0.0, 0.0, 2.0}, {0.0, 0.0, -2.0},
  133.         {1.61803, 0.618034, 1.0}, {1.61803, 0.618034, -1.0},
  134.         {1.61803, -0.618034, 1.0}, {1.61803, -0.618034, -1.0},
  135.         {-1.61803, 0.618034, 1.0}, {-1.61803, 0.618034, -1.0},
  136.         {-1.61803, -0.618034, 1.0}, {-1.61803, -0.618034, -1.0},
  137.         {1.0, 1.61803, 0.618034}, {1.0, 1.61803, -0.618034},
  138.         {1.0, -1.61803, 0.618034}, {1.0, -1.61803, -0.618034},
  139.         {-1.0, 1.61803, 0.618034}, {-1.0, 1.61803, -0.618034},
  140.         {-1.0, -1.61803, 0.618034}, {-1.0, -1.61803, -0.618034},
  141.         {0.618034, 1.0, 1.61803}, {0.618034, 1.0, -1.61803},
  142.         {0.618034, -1.0, 1.61803}, {0.618034, -1.0, -1.61803},
  143.         {-0.618034, 1.0, 1.61803}, {-0.618034, 1.0, -1.61803},
  144.         {-0.618034, -1.0, 1.61803}, {-0.618034, -1.0, -1.61803}};
  145.  
  146. main(argc,argv)
  147.   int argc;
  148.   char *argv[];
  149. {char *s;
  150.  int cnt;
  151.  
  152.  cnt = 1;
  153.  while (--argc > 0 && argv[cnt][0] == '-')
  154.   {s = argv[cnt]+1;
  155.    switch (*s)
  156.     {case 'C':
  157.        makecube();
  158.        break;
  159.      case 'c':
  160.        makecubeocta();
  161.        break;
  162.      case 'D':
  163.        makedodeca();
  164.        break;
  165.      case 'h':
  166.        makeheader();
  167.        break;
  168.      case 'I':
  169.        makeicosa();
  170.        break;
  171.      case 'i':
  172.        makeicosidodeca();
  173.        break;
  174.      case 'O':
  175.        makeocta();
  176.        break;
  177.      case 's':
  178.        sscanf(argv[cnt]+2,"%f",&scale);
  179.        break;
  180.      case 'T':
  181.        maketetra();
  182.        break;
  183.      case 'x':
  184.        sscanf(argv[cnt]+2,"%f",&tx);
  185.        break;
  186.      case 'y':
  187.        sscanf(argv[cnt]+2,"%f",&ty);
  188.        break;
  189.      case 'z':
  190.        sscanf(argv[cnt]+2,"%f",&tz);
  191.        break;
  192.      default: printf("argv[%d]=%s\n",cnt,argv[cnt]);
  193.        break;
  194.     }
  195.    cnt++;
  196.   }
  197. }
  198.  
  199. makeheader()
  200. {printf("v\nfrom 0 0 1\nat 0 0 0\nup 0 1 0\nangle 45\nhither 1\n");
  201.  printf("resolution 512 512\nb 0 0 0\nl 0 1 1\n");
  202. }
  203.  
  204. maketetra()
  205. {printf("#tetrahedron: 4 polygons\n");
  206.  printf("#f 0 0 0 0 0 0 0 0\n");
  207.  tri(tetra,0,1,2);
  208.  tri(tetra,0,1,3);
  209.  tri(tetra,0,2,3);
  210.  tri(tetra,1,2,3);
  211. }
  212.  
  213. makecube()
  214. {printf("#cube: 6 polygons\n");
  215.  printf("#f 0 0 0 0 0 0 0 0\n");
  216.  quad(cube,0,1,2,3);
  217.  quad(cube,0,3,4,5);
  218.  quad(cube,0,1,6,5);
  219.  quad(cube,1,2,7,6);
  220.  quad(cube,2,3,4,7);
  221.  quad(cube,4,5,6,7);
  222. }
  223.  
  224. makeocta()
  225. {printf("#octahedron: 8 polygons\n");
  226.  printf("#f 0 0 0 0 0 0 0 0\n");
  227.  tri(octa,0,2,4);
  228.  tri(octa,0,2,5);
  229.  tri(octa,0,3,4);
  230.  tri(octa,0,3,5);
  231.  tri(octa,1,2,4);
  232.  tri(octa,1,2,5);
  233.  tri(octa,1,3,4);
  234.  tri(octa,1,3,5);
  235. }
  236.  
  237. makecubeocta()
  238. {printf("#cubeoctahedron: 14 polygons\n");
  239.  printf("#f 0 0 0 0 0 0 0 0\n");
  240.  tri(cubeocta,0,4,8);
  241.  tri(cubeocta,0,5,9);
  242.  tri(cubeocta,1,4,11);
  243.  tri(cubeocta,1,5,10);
  244.  tri(cubeocta,2,6,10);
  245.  tri(cubeocta,2,7,11);
  246.  tri(cubeocta,3,6,9);
  247.  tri(cubeocta,3,7,8);
  248.  quad(cubeocta,0,8,3,9);
  249.  quad(cubeocta,0,5,1,4);
  250.  quad(cubeocta,1,11,2,10);
  251.  quad(cubeocta,2,7,3,6);
  252.  quad(cubeocta,4,11,7,8);
  253.  quad(cubeocta,5,10,6,9);
  254. }
  255.  
  256. makeicosa()
  257. {printf("#icosahedron: 20 polygons\n");
  258.  printf("#f 0 0 0 0 0 0 0 0\n");
  259.  tri(icosa,0,4,5);
  260.  tri(icosa,0,4,8);
  261.  tri(icosa,4,8,10);
  262.  tri(icosa,1,4,10);
  263.  tri(icosa,1,4,5);
  264.  tri(icosa,1,5,11);
  265.  tri(icosa,5,9,11);
  266.  tri(icosa,0,5,9);
  267.  tri(icosa,0,2,9);
  268.  tri(icosa,0,2,8);
  269.  tri(icosa,1,3,11);
  270.  tri(icosa,1,3,10);
  271.  tri(icosa,2,6,7);
  272.  tri(icosa,2,6,8);
  273.  tri(icosa,6,8,10);
  274.  tri(icosa,3,6,10);
  275.  tri(icosa,3,6,7);
  276.  tri(icosa,3,7,11);
  277.  tri(icosa,7,9,11);
  278.  tri(icosa,2,7,9);
  279. }
  280.  
  281. makedodeca()
  282. {printf("#dodecahedron: 12 polygons\n");
  283.  printf("#f 0 0 0 0 0 0 0 0\n");
  284.  pent(dodeca,0,1,15,4,12);
  285.  pent(dodeca,0,12,8,9,13);
  286.  pent(dodeca,0,13,5,14,1);
  287.  pent(dodeca,1,14,10,11,15);
  288.  pent(dodeca,2,3,17,7,16);
  289.  pent(dodeca,2,16,11,10,19);
  290.  pent(dodeca,2,19,6,18,3);
  291.  pent(dodeca,3,17,8,9,18);
  292.  pent(dodeca,4,7,16,11,15);
  293.  pent(dodeca,4,7,17,8,12);
  294.  pent(dodeca,5,6,18,9,13);
  295.  pent(dodeca,5,6,19,10,14);
  296. }
  297.  
  298. makeicosidodeca()
  299. {printf("#icosidodecahedron: 32 polygons\n");
  300.  printf("#f 0 0 0 0 0 0 0 0\n");
  301.  pent(icosidodeca,0,6,14,15,7);
  302.  pent(icosidodeca,0,8,16,17,9);
  303.  pent(icosidodeca,1,10,18,19,11);
  304.  pent(icosidodeca,1,12,20,21,13);
  305.  pent(icosidodeca,2,14,22,26,18);
  306.  pent(icosidodeca,2,15,23,27,19);
  307.  pent(icosidodeca,3,16,24,28,20);
  308.  pent(icosidodeca,3,17,25,29,21);
  309.  pent(icosidodeca,4,22,6,8,24);
  310.  pent(icosidodeca,4,26,10,12,28);
  311.  pent(icosidodeca,5,23,7,9,25);
  312.  pent(icosidodeca,5,27,11,13,29);
  313.  tri(icosidodeca,0,6,8);
  314.  tri(icosidodeca,0,7,9);
  315.  tri(icosidodeca,1,10,12);
  316.  tri(icosidodeca,1,11,13);
  317.  tri(icosidodeca,2,14,15);
  318.  tri(icosidodeca,2,18,19);
  319.  tri(icosidodeca,3,16,17);
  320.  tri(icosidodeca,3,20,21);
  321.  tri(icosidodeca,4,22,26);
  322.  tri(icosidodeca,4,24,28);
  323.  tri(icosidodeca,5,23,27);
  324.  tri(icosidodeca,5,25,29);
  325.  tri(icosidodeca,6,14,22);
  326.  tri(icosidodeca,7,15,23);
  327.  tri(icosidodeca,8,16,24);
  328.  tri(icosidodeca,9,17,25);
  329.  tri(icosidodeca,10,18,26);
  330.  tri(icosidodeca,11,19,27);
  331.  tri(icosidodeca,12,20,28);
  332.  tri(icosidodeca,13,21,29);
  333. }
  334.  
  335. tri(a,p1,p2,p3)
  336.   POINT *a;
  337.   int p1, p2, p3;
  338. {printf("p 3\n");
  339.  prtpt(a,p1);
  340.  prtpt(a,p2);
  341.  prtpt(a,p3);
  342. }
  343.  
  344. quad(a,p1,p2,p3,p4)
  345.   POINT *a;
  346.   int p1, p2, p3, p4;
  347. {printf("p 4\n");
  348.  prtpt(a,p1);
  349.  prtpt(a,p2);
  350.  prtpt(a,p3);
  351.  prtpt(a,p4);
  352. }
  353.  
  354. pent(a,p1,p2,p3,p4,p5)
  355.   POINT *a;
  356.   int p1, p2, p3, p4, p5;
  357. {printf("p 5\n");
  358.  prtpt(a,p1);
  359.  prtpt(a,p2);
  360.  prtpt(a,p3);
  361.  prtpt(a,p4);
  362.  prtpt(a,p5);
  363. }
  364.  
  365. prtpt(a,p)
  366.   POINT *a;
  367.   int p;
  368. {printf("%g %g %g\n",scale*a[p].x+tx,scale*a[p].y+ty,scale*a[p].z+tz);
  369. }
  370.  
  371. --
  372. Moderated by SCRI Vis <>           Submissions to: graphics@scri1.scri.fsu.edu
  373. Guy, John R. Murray   <> Administrivia to: graphics-request@scri1.scri.fsu.edu
  374.  
  375. ======================================================================== 167
  376. Received: from UKACRL by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 5141; Thu, 21
  377.  May 92 19:25:13 BST
  378. Received:
  379.            from UKACRL by UKACRL.BITNET (Mailer R2.07) with BSMTP id 2429; Thu,
  380.                21 May 92 19:24:40 BST
  381. Received:      from psi.rutgers.edu by ib.rl.ac.uk (IBM VM SMTP V2R1) with TCP;
  382.                Thu, 21 May 92 19:24:33 BS
  383. Received:      from RUTGERS.EDU by psi.rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
  384.                 id AA21051; Thu, 21 May 92 14:24:09 ED
  385. Received:      by rutgers.edu (5.59/SMI4.0/RU1.4/3.08)
  386.                 id AA12619; Thu, 21 May 92 14:24:07 ED
  387. Message-Id:    <9205211824.AA12619@rutgers.edu>
  388. Reply-To:      comp-graphics-research@EDU.RUTGERS.VIZLAB
  389. From:          wilson@EDU.UCF.CS.OSCEOLA
  390. Subject:       (NFF) Soccerball Platonic Solid Generator: soccerball.c
  391. Date:          21 May 92 17:14:21 GMT
  392. Sender:        news@EDU.FSU.SCRI.SUN13
  393. Followup-To:   comp.graphics
  394. Approved:      murray@vs6.scri.fsu.edu
  395. X-Submissions-To: graphics@scri1.scri.fsu.edu
  396. X-Administrivia-To: graphics-request@scri1.scri.fsu.edu
  397. Apparently-To: comp-graphics-research-dist@vizlab.rutgers.edu
  398.  
  399. /*
  400. Soccerball Platonic Solid Generator by Tom Wilson, 1992
  401.  
  402. Believe it or not the points needed to generate a soccerball can be derived
  403. from the points on an icosahedron. Unfortunately, this generates flat panels
  404. whereas a real soccerball has curved surfaces when inflated. Oh well, I used
  405. smooth shading (pp in NFF) to help it look better. It looks realistic except
  406. for the edges which are obviously planar. A soccerball is not really a
  407. platonic solid (but neither is a teapot 8-). No scaling or translating is
  408. allowed.
  409.  
  410. */
  411.  
  412. #include <stdio.h>
  413. #include <math.h>
  414.  
  415. double dot();
  416.  
  417. typedef struct pointrec
  418.           {double x, y, z;
  419.           } POINT;
  420.  
  421. typedef struct ptrec
  422.          {POINT p[5];
  423.           int n;
  424.          } PENTPOINT;
  425.  
  426. POINT icosahedron[12] =
  427.        {{0.0, 1.61803, 1.0}, {0.0, -1.61803, 1.0}, {0.0, 1.61803, -1.0},
  428.         {0.0, -1.61803, -1.0}, {1.0, 0.0, 1.61803}, {-1.0, 0.0, 1.61803},
  429.         {1.0, 0.0, -1.61803}, {-1.0, 0.0, -1.61803}, {1.61803, 1.0, 0.0},
  430.         {-1.61803, 1.0, 0.0}, {1.61803, -1.0, 0.0}, {-1.61803, -1.0, 0.0}};
  431. PENTPOINT pentagons[12];
  432.  
  433. main()
  434. {int t, w;
  435.  double l;
  436.  
  437.  printf("v\nfrom 3 8 8\nat 0 0 0\nup 0 1 0\nangle 45\nhither 1\n");
  438.  printf("resolution 512 512\nb 0 1 0\nl 10 10 5\nl -10 10 5\nl 10 10 -5\nl -10
  439.  -10 5\n");
  440.  printf("f 1 1 1 1 0 0 0 0\n");
  441.  printf("#32 polygons\n");
  442.  hexagon(0,8,4);
  443.  hexagon(0,4,5);
  444.  hexagon(0,5,9);
  445.  hexagon(0,9,2);
  446.  hexagon(0,2,8);
  447.  hexagon(1,4,10);
  448.  hexagon(1,5,4);
  449.  hexagon(1,11,5);
  450.  hexagon(1,3,11);
  451.  hexagon(1,10,3);
  452.  hexagon(2,6,8);
  453.  hexagon(2,7,6);
  454.  hexagon(2,9,7);
  455.  hexagon(4,8,10);
  456.  hexagon(5,11,9);
  457.  hexagon(6,10,8);
  458.  hexagon(3,10,6);
  459.  hexagon(3,6,7);
  460.  hexagon(3,7,11);
  461.  hexagon(7,9,11);
  462.  printf("f 0 0 0 1 0 0 0 0\n");
  463.  for (t = 0; t < 12; t++)
  464.   {fixpts(t);
  465.    printf("pp 5\n");
  466.    for (w = 0; w < 5; w++)
  467.     {printf("%g %g %g ",pentagons[t].p[w].x,pentagons[t].p[w].y,
  468.             pentagons[t].p[w].z);
  469.      l = sqrt(pentagons[t].p[w].x*pentagons[t].p[w].x +
  470.               pentagons[t].p[w].y*pentagons[t].p[w].y +
  471.               pentagons[t].p[w].z*pentagons[t].p[w].z);
  472.      printf("%g %g %g\n",pentagons[t].p[w].x/l,pentagons[t].p[w].y/l,
  473.             pentagons[t].p[w].z/l);
  474.     }
  475.   }
  476. }
  477.  
  478. arccos(a)
  479.   double a;
  480. {return (int) (acos(a)*180.0/3.1415926);
  481. }
  482.  
  483. fixpts(t)
  484.   int t;
  485. {POINT pt;
  486.  int w, v;
  487.  
  488.  for (w = 0; w < 3; w++)
  489.    for (v = w+1; v < 5; v++)
  490.      if (arccos(dot(pentagons[t].p[w],pentagons[t].p[v])) == 23)
  491.        if (v == w+1)
  492.          break;
  493.        else {pt = pentagons[t].p[w+1];
  494.              pentagons[t].p[w+1] = pentagons[t].p[v];
  495.              pentagons[t].p[v] = pt;
  496.              break;
  497.             }
  498. }
  499.  
  500. double dot(p1,p2)
  501.   POINT p1, p2;
  502. {double x, y, z, l1, l2;
  503.  
  504.  l1 = sqrt(p1.x*p1.x+p1.y*p1.y+p1.z*p1.z);
  505.  l2 = sqrt(p2.x*p2.x+p2.y*p2.y+p2.z*p2.z);
  506.  return (p1.x*p2.x + p1.y*p2.y + p1.z*p2.z)/(l1*l2);
  507. }
  508.  
  509. hexagon(p1,p2,p3)
  510.   int p1, p2, p3;
  511. {printf("pp 6\n");
  512.  make2pts(p1,p2);
  513.  make2pts(p2,p3);
  514.  make2pts(p3,p1);
  515. }
  516.  
  517. make2pts(p1,p2)
  518.   int p1, p2;
  519. {POINT pa, pb;
  520.  double l;
  521.  int t;
  522.  
  523.  pa.x = icosahedron[p2].x + 2.0/3.0*(icosahedron[p1].x-icosahedron[p2].x);
  524.  pa.y = icosahedron[p2].y + 2.0/3.0*(icosahedron[p1].y-icosahedron[p2].y);
  525.  pa.z = icosahedron[p2].z + 2.0/3.0*(icosahedron[p1].z-icosahedron[p2].z);
  526.  pb.x = icosahedron[p2].x + 1.0/3.0*(icosahedron[p1].x-icosahedron[p2].x);
  527.  pb.y = icosahedron[p2].y + 1.0/3.0*(icosahedron[p1].y-icosahedron[p2].y);
  528.  pb.z = icosahedron[p2].z + 1.0/3.0*(icosahedron[p1].z-icosahedron[p2].z);
  529.  printf("%g %g %g ",pa.x,pa.y,pa.z);
  530.  l = sqrt(pa.x*pa.x + pa.y*pa.y + pa.z*pa.z);
  531.  printf("%g %g %g\n",pa.x/l,pa.y/l,pa.z/l);
  532.  printf("%g %g %g ",pb.x,pb.y,pb.z);
  533.  l = sqrt(pb.x*pb.x + pb.y*pb.y + pb.z*pb.z);
  534.  printf("%g %g %g\n",pb.x/l,pb.y/l,pb.z/l);
  535.  t = pentagons[p1].n++;
  536.  pentagons[p1].p[t] = pa;
  537. }
  538.  
  539. --
  540. Moderated by SCRI Vis <>           Submissions to: graphics@scri1.scri.fsu.edu
  541. Guy, John R. Murray   <> Administrivia to: graphics-request@scri1.scri.fsu.edu
  542.  
  543. ======================================================================== 30
  544. Received:
  545.            from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 2679; Tue, 07
  546.                May 91 18:49:22 BST
  547. Via:           UK.AC.NSF;  7 MAY 91 18:49:19 BST
  548. Received:      from vax.nsfnet-relay.ac.uk by sun2.nsfnet-relay.ac.uk
  549.                with SMTP inbound id <12272-34@sun2.nsfnet-relay.ac.uk>;
  550.                Tue, 7 May 1991 16:32:22 +01
  551. Received:      from aramis.rutgers.edu by vax.NSFnet-Relay.AC.UK via NSFnet
  552.                with SMTP id aa08913; 7 May 91 15:00 BS
  553. Received:      by aramis.rutgers.edu (5.59/SMI4.0/RU1.4/3.08) id AA16046;
  554.                Tue, 7 May 91 10:04:17 ED
  555. Message-Id:    <9105071404.AA16046@aramis.rutgers.edu>
  556. Reply-To:      comp-visualization@edu.rutgers.cs
  557. From:          sulaiman@edu.umass.ecs
  558. Subject:       Icosahedron help
  559. Date:          6 May 91 13:02:31 GMT
  560. Apparently-To: comp-visualization-dist@cs.rutgers.edu
  561.  
  562.  
  563.  I need to find out how you would define the equations for all 12
  564. planes of an icosahedron centered at 0,0,0. I am building a ray tracer
  565. and i need to compute hit times (t in and t out) for several platonic solids
  566. including .... an icosahedron ...
  567.  
  568. Thanx
  569.  
  570. P.S. I guess I need the equations for each plane. The vertices and edges
  571. I think I already have figured out. oooops replace all reference to 'planes'
  572. with 'faces'
  573.