shapes = np.array([[[1, 4], [4, 2], [11, 2], [14, 0]], [[4, 5], [4, 2], [11,
    2], [13, 0]], [[1, 3], [4, 2], [11, 2], [14, 1.5]], [[3, 5], [4, 2], [
    10, 7], [7, 9]], [[5, 5], [4, 2], [10, 7], [6, 6]]])

def random_rotation():
    theta = 3 * np.pi * np.random.random()
rotMatrix = numpy.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta),
    np.cos(theta)]])
return rotMatrix
new_shapes = []
for s in shapes:
    rr = random_rotation()
new_shapes += [[(list(rr.dot(p)) + [0]) for p in s]]
new_shapes = np.array(new_shapes)
for i, s in enumerate(new_shapes):
    plot(s[:, (0)], s[:, (1)], color='black')
text(np.mean(s[:, (0)]), np.mean(s[:, (1)]), str(i), fontsize=14)
Clustering structural 3D data