# icosahedron

Dec 14th, 2016
144
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #define X 0,525731112119133606
2. #define Z 0,850650808352039932
3.
4.  Unit length vertices, t = (1 + sqrt(5))/2, s = sqrt(1 + t * t), t * s = sqrt(5 + 2 * sqrt(5)):
5. v0 = (t, 1, 0)/s v3 = (−t, −1, 0)/s v6 = (1, 0, t)/s v9 = (0, −t, 1)/s
6. v1 = (−t, 1, 0)/s v4 = (1, 0, t)/s v7 = (1, 0, −t)/s v10 = (0, t, −1)/s
7. v2 = (t, −1, 0)/s v5 = (1, 0, −t)/s v8 = (0, t, 1)/s v11 = (0, −t, −1)/s
8.
9. //-----------------------------------------------------------------------
10.
11. static GLfloat vdata[12][3] = {
12.     {-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z},
13.     {0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X},
14.     {Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0}
15. };
16.
17.
18. static GLuint tindices [20][3] = {
19.     {1, 4, 0}, {4, 9, 0}, {4, 5, 9}, {8, 5, 4}, {1, 8, 4},
20.     {1, 10, 8}, {10, 3, 8}, {8, 3, 5}, {3, 2, 5}, {3, 7, 2},
21.     {3, 10, 7}, {10, 6, 7}, {6, 11, 7}, {6, 0, 11}, {6, 1, 0},
22.     {10, 1, 6}, {11, 0, 9}, {2, 11, 9}, {5, 2, 9}, {11, 2, 7},
23. };
24.
25.     int i;
26.     glBegin(GL_TRIANGLES);
27.     for(i=0; i<20;i++) {
28.     glColor3f(1.0,0.0,0.0);
29.     glVertex3fv(&vdata[tindices[i][0]][0]);
30.     glVertex3fv(&vdata[tindices[i][1]][0]);
31.     glVertex3fv(&vdata[tindices[i][2]][0]);
32.     }
33.     glEnd();
RAW Paste Data