def principal_direction_extent(points):
<EOL>points = np.copy(points)<EOL>points -= np.mean(points, axis=<NUM_LIT:0>)<EOL>_, eigv = pca(points)<EOL>extent = np.zeros(<NUM_LIT:3>)<EOL>for i in range(eigv.shape[<NUM_LIT:1>]):<EOL><INDENT>scalar_projs = np.sort(np.array([np.dot(p, eigv[:, i]) for p in points]))<EOL>extent[i] = scalar_projs[-<NUM_LIT:1>]<EOL>if scalar_projs[<NUM_LIT:0>] < <NUM_LIT:0.>:<EOL><INDENT>extent -= scalar_projs[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return extent<EOL>
Calculate the extent of a set of 3D points.

   The extent is defined as the maximum distance between
   the projections on the principal directions of the covariance matrix
   of the points.

   Parameter:
       points : a 2D numpy array of points

   Returns:
       extents : the extents for each of the eigenvectors of the cov matrix
       eigs : eigenvalues of the covariance matrix
       eigv : respective eigenvectors of the covariance matrix