def calcFitError(pts):
    
    # this computes the outer product of each vector
    # in the array, element-wise, then sums up the 3x3
    # matrices
    #  A = sum{v_i * v_i^T} 
    A = numpy.sum(pts[...,None] * pts[:,None,:], 0)
    
    # b = mean(v_i)
    b = numpy.mean(pts, 0)

    # Z = A - (b * b^T) / c
    Z = A - numpy.outer(b,b) / len(pts)
    
    # n (normal of best fit plane) is the eigenvector
    # corresponding to the minimum eigenvalue
    eigvals, eigvecs = numpy.linalg.eigh(Z)
    n = eigvecs[numpy.argmin(eigvals)]
    
    # d (scalar offset of best fit plane) = -n^T * b / c
    d = numpy.inner(-n, b)
    
    # final error is the square of the mean distance of each point to the plane
    mean_dist = numpy.mean(numpy.abs(numpy.dot(pts, n) + d))
    Efit = mean_dist * mean_dist
    
    return Efit
Calculates E_fit, which is an error value from
dataset/ETHPy150Open pycollada/meshtool/meshtool/filters/simplify_filters/sander_simplify.py/calcFitError