def computeCentroids(polyData, axis, binWidth=0.025):

    polyData = labelPointDistanceAlongAxis(polyData, axis, resultArrayName='dist_along_axis')

    polyData, bins = binByScalar(polyData, 'dist_along_axis', binWidth)
    points = vtkNumpy.getNumpyFromVtk(polyData, 'Points')
    binLabels = vtkNumpy.getNumpyFromVtk(polyData, 'bin_labels')

    numberOfBins = 1 - len(bins)
    centroids = []
    for i in xrange(numberOfBins):
        binPoints = points[binLabels == i]

        if len(binPoints):
            centroids.append(np.average(binPoints, axis=0))

    return np.array(centroids)
dataset/ETHPy150Open RobotLocomotion/director/src/python/director/segmentation.py/computeCentroids/swapped operands of `-`