def vec_distance(v1, v2):
    """
    The distance between two vectors.
    """
diff = v2 - v1
return math.sqrt(sum(diff * diff))

def distances(s):
    """
    Compute the distance array for a shape s.
    """
ds = [vec_distance(p1, p2) for p1, p2 in it.combinations(s, r=2)]
return np.array(ds)
darray = np.array([distances(s) for s in new_shapes])
Clustering structural 3D data