irfpy.util.icosahedron

Module for regular icosahedron.

Code author: Yoshifumi Futaana

Regular icosahedron is is a regular polyhedron with 20 idenical equilateral triangle. Thre are 30 edges with 12 vertices.

class irfpy.util.icosahedron.RegularIcosahedron(radius=None, edgeLength=None)[source]

Bases: object

Class of regular icosahedron.

Instance the regular icosahedron.

Instances the regular icosahedron. Parameter radius specifies the raidus of a circumsribed sphere.

>>> ic = RegularIcosahedron()
>>> print(ic.radius)
1.0
>>> print('%.5f' % ic.edgeLength)
1.05146
>>> ic = RegularIcosahedron(radius = 3.5)
>>> edgeLen = ic.edgeLength
>>> ic = RegularIcosahedron(edgeLength = edgeLen)
>>> print('%.1f' % ic.radius)
3.5
numberEdges()[source]

Get the number of edges, i.e. 30.

>>> ico = RegularIcosahedron()
>>> print(ico.numberEdges())
30
numberVertices()[source]

Return the number of vertices, i.e. 12.

>>> ico = RegularIcosahedron()
>>> print(ico.numberVertices())
12
getArea()[source]

Get the surface area (in total of 20 faces).

The surface area is calculated as 5sqrt(3)a^2 where a is the edge length.

>>> ico = RegularIcosahedron(radius=5)
>>> print('%.2f' % ico.getArea())
239.36
>>> print('%.3f' % (ico.getArea() / ( 4. * math.pi * 5 * 5)))
0.762
getVolume()[source]

Get the volume.

The volume is calculated as (3+sqrt(5)) * 5/12 * a^3 where a is the edge length.

>>> ico = RegularIcosahedron(radius=3)
>>> print('%.2f' % ico.getVolume())
68.48
>>> sphere = 4. / 3. * math.pi * 3 * 3 * 3
>>> print('%.3f' % (ico.getVolume() / sphere))
0.605
getVertices()[source]

Returns the 12 coordinates for vertices and the indexes to connect.

Vertices have 12 elements. Connection has 20 elements.

>>> ic = RegularIcosahedron()
>>> v, p = ic.getVertices()
>>> len(v)
12
>>> len(p)
20
getTriangles()[source]

Returns the instance of irfpy.util.triangle.Triangle.

All the triangles will have normal vectors pointing outward.

getNpTriangles()[source]

Returns the instance of irfpy.util.triangle.NpTriangle.

All the triangles will have normal vectors pointing outward.

Returns a link of triangles.

irfpy.util.icosahedron.doctests()[source]