Understanding the geometry of a truncated Icosahed

2019-07-16 20:14发布

enter image description here

I'm trying to render a truncated icosahedron like above with clickable zones using Three.js.

I found the code for a regular icosahedron

var t = ( 1 + Math.sqrt( 5 ) ) / 2;

var vertices = [
    [ -1,  t,  0 ], [  1, t, 0 ], [ -1, -t,  0 ], [  1, -t,  0 ],
    [  0, -1,  t ], [  0, 1, t ], [  0, -1, -t ], [  0,  1, -t ],
    [  t,  0, -1 ], [  t, 0, 1 ], [ -t,  0, -1 ], [ -t,  0,  1 ]
];

var faces = [
    [ 0, 11,  5 ], [ 0,  5,  1 ], [  0,  1,  7 ], [  0,  7, 10 ], [  0, 10, 11 ],
    [ 1,  5,  9 ], [ 5, 11,  4 ], [ 11, 10,  2 ], [ 10,  7,  6 ], [  7,  1,  8 ],
    [ 3,  9,  4 ], [ 3,  4,  2 ], [  3,  2,  6 ], [  3,  6,  8 ], [  3,  8,  9 ],
    [ 4,  9,  5 ], [ 2,  4, 11 ], [  6,  2, 10 ], [  8,  6,  7 ], [  9,  8,  1 ]
];

THREE.PolyhedronGeometry.call( this, vertices, faces, radius, detail );

And drew the conclusion that t is φ & vertices consists of all the permutations of:

(0, ±1, ±φ) (±1, ±φ, 0) (±φ, 0, ±1) - From Here

So I modified my vertices as per:

(0, ±1, ±3φ) (±2, ±(1+2φ), ±φ) (±1, ±(2+φ), ±2φ) - From Here

Resulting in:

var vertices = [
        [-2, (1+2*t,t], [2,(1+2*t), t ], [-2,-(1+2*t),-t], [2,-(1+2*t),-t ],
        [0,-1,3*t], [0,1,3*t], [0,-1,-3*t], [0,1,-3*t],
        [1,-(2+t),-2*t ],[1,(2+t),2*t],[-1,-(2+t),-2*t],[-1,(2+t),2*t]
];

Now I understand I have to modify the faces as well. Icosahedron seems to have 20 triangular faces & I can construct any polygon in Three.js with triangles, only.

Does it then follow, that I need the coordinates for 5 pentagons & 12 hexagons in the form of:

5 * 12 + 6 * 20 = 180 triangles

If so, how should I proceed in generating those coordinates? Or even if I am wrong regarding the whole thing.

1条回答
霸刀☆藐视天下
2楼-- · 2019-07-16 20:53

The JSModeler framework can generate a lot of solids, including truncated icosahedron, so maybe the source can help you.

You can find the code here if you find for GenerateTruncatedIcosahedron: https://github.com/kovacsv/JSModeler/blob/master/src/extras/solidgenerator.js

The code creates polygons with five and six vertices, but it is easy to replace them with triangles.

查看更多
登录 后发表回答