shape.py
def octahedron(name, center, rad, shade = 1, rand = False, isosceles = False):
    """
    Returns (possibly randomly oriented) octahedron shape object
    centered at 'center' with radius 'rad'.
    """
    center = np.asarray(center)
    v0 = np.array([ 1,  1, 0]) + center
    v1 = np.array([ 1, -1, 0]) + center
    v2 = np.array([-1,  1, 0]) + center
    v3 = np.array([-1, -1, 0]) + center
    if isosceles:
        v4 = np.array([0, 0,  1/np.sqrt(2)]) + center
        v5 = np.array([0, 0, -1/np.sqrt(2)]) + center
    else:
        v4 = np.array([0, 0, np.sqrt(2)]) + center
        v5 = np.array([0, 0, -np.sqrt(2)]) + center
    shp = shape(name = name, shade = shade, dims = 3)
    shp.add_nodes_from([(0, {'pos': v0}), (1, {'pos': v1}),
                        (2, {'pos': v2}), (3, {'pos': v3}),
                        (4, {'pos': v4}), (5, {'pos': v5})])
    shp.add_edges_from([(0, 1), (0, 2), (1, 3), (2, 3),
                        (0, 4), (1, 4), (2, 4), (3, 4),
                        (0, 5), (1, 5), (2, 5), (3, 5)])
    factor = rad / np.linalg.norm(v4 - shp.get_com())
    shp.scale(factor)
    if rand:
        shp.rotate3d(axis = np.random.rand(3), angle = 2*math.pi*np.random.rand())
    return shp

    Returns (possibly randomly oriented) octahedron shape object
    centered at 'center' with radius 'rad'.
    
Returns (possibly randomly oriented) octahedron shape object
centered at 'center' with radius 'rad'.
Returns ( possibly randomly oriented ) octahedron shape object centered at ' center ' with radius ' rad ' .
def octahedron(name, center, rad, shade = 1, rand = False, isosceles = False):
    center = np.asarray(center)
    v0 = np.array([ 1,  1, 0]) + center
    v1 = np.array([ 1, -1, 0]) + center
    v2 = np.array([-1,  1, 0]) + center
    v3 = np.array([-1, -1, 0]) + center
    if isosceles:
        v4 = np.array([0, 0,  1/np.sqrt(2)]) + center
        v5 = np.array([0, 0, -1/np.sqrt(2)]) + center
    else:
        v4 = np.array([0, 0, np.sqrt(2)]) + center
        v5 = np.array([0, 0, -np.sqrt(2)]) + center
    shp = shape(name = name, shade = shade, dims = 3)
    shp.add_nodes_from([(0, {'pos': v0}), (1, {'pos': v1}),
                        (2, {'pos': v2}), (3, {'pos': v3}),
                        (4, {'pos': v4}), (5, {'pos': v5})])
    shp.add_edges_from([(0, 1), (0, 2), (1, 3), (2, 3),
                        (0, 4), (1, 4), (2, 4), (3, 4),
                        (0, 5), (1, 5), (2, 5), (3, 5)])
    factor = rad / np.linalg.norm(v4 - shp.get_com())
    shp.scale(factor)
    if rand:
        shp.rotate3d(axis = np.random.rand(3), angle = 2*math.pi*np.random.rand())
    return shp
def octahedron ( name , center , rad , shade = 1 , rand = False , isosceles = False ) : center = np . asarray ( center ) v0 = np . array ( [ 1 , 1 , 0 ] ) + center v1 = np . array ( [ 1 , - 1 , 0 ] ) + center v2 = np . array ( [ - 1 , 1 , 0 ] ) + center v3 = np . array ( [ - 1 , - 1 , 0 ] ) + center if isosceles : v4 = np . array ( [ 0 , 0 , 1 / np . sqrt ( 2 ) ] ) + center v5 = np . array ( [ 0 , 0 , - 1 / np . sqrt ( 2 ) ] ) + center else : v4 = np . array ( [ 0 , 0 , np . sqrt ( 2 ) ] ) + center v5 = np . array ( [ 0 , 0 , - np . sqrt ( 2 ) ] ) + center shp = shape ( name = name , shade = shade , dims = 3 ) shp . add_nodes_from ( [ ( 0 , { 'pos' : v0 } ) , ( 1 , { 'pos' : v1 } ) , ( 2 , { 'pos' : v2 } ) , ( 3 , { 'pos' : v3 } ) , ( 4 , { 'pos' : v4 } ) , ( 5 , { 'pos' : v5 } ) ] ) shp . add_edges_from ( [ ( 0 , 1 ) , ( 0 , 2 ) , ( 1 , 3 ) , ( 2 , 3 ) , ( 0 , 4 ) , ( 1 , 4 ) , ( 2 , 4 ) , ( 3 , 4 ) , ( 0 , 5 ) , ( 1 , 5 ) , ( 2 , 5 ) , ( 3 , 5 ) ] ) factor = rad / np . linalg . norm ( v4 - shp . get_com ( ) ) shp . scale ( factor ) if rand : shp . rotate3d ( axis = np . random . rand ( 3 ) , angle = 2 * math . pi * np . random . rand ( ) ) return shp
Returns (possibly randomly oriented) octahedron shape object
centered at 'center' with radius 'rad'.
Returns ( possibly randomly oriented ) octahedron shape object centered at ' center ' with radius ' rad ' .
"""
    Returns (possibly randomly oriented) octahedron shape object
    centered at 'center' with radius 'rad'.
    """
name
center
rad
shade
rand
isosceles