INNER CODE UNIT · Python
mid
TheOpenSpaceProgram/osp-magnum · scripts/icosahedron_tables.py:41
def mid(a, b):
return (0.5*(a[0]+b[0]), 0.5*(a[1]+b[1]), 0.5*(a[2]+b[2]))
def mag(a):
return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2])
def norm(a):
m = mag(a)
return (a[0]/m, a[1]/m, a[2]/m)
def distance(a, b):
return mag((b[0]-a[0], b[1]-a[1], b[2]-a[2]))
# -----------------------------------------------------------------------------
# Create an Icosahedron. Blender style, so there's a vertex directly on
# top and directly on the bottom. Basicly, a sandwich of two pentagons,
# rotated 180 apart from each other, and each 1/sqrt(5) above and below