def sortFittedDrills(fitResults, robotOrigin, robotForward):

    angleToFitResults = []

    for fitResult in fitResults:
        cluster, drillFrame = fitResult
        drillOrigin = np.array(drillFrame.GetPosition())
        angleToDrill = np.abs(computeSignedAngleBetweenVectors(robotForward, robotOrigin - drillOrigin, [0,0,1]))
        angleToFitResults.append((angleToDrill, cluster, drillFrame))
        #print 'angle to candidate drill:', angleToDrill

    angleToFitResults.sort(key=lambda x: x[0])

    #print 'using drill at angle:', angleToFitResults[0][0]

    drillMesh = getDrillBarrelMesh()

    for i, fitResult in enumerate(angleToFitResults):

        angleToDrill, cluster, drillFrame = fitResult

        if i == 0:

            drill = om.findObjectByName('drill')
            drill = updatePolyData(drillMesh, 'drill', color=[0, 1, 0], cls=FrameAffordanceItem, visible=True)
            drillFrame = updateFrame(drillFrame, 'drill frame', parent=drill, visible=False)
            drill.actor.SetUserTransform(drillFrame.transform)

            drill.setAffordanceParams(dict(otdf_type='dewalt_button', friendly_name='dewalt_button'))
            drill.updateParamsFromActorTransform()

            drill.setSolidColor([0, 1, 0])
            #cluster.setProperty('Visible', True)

        else:

            drill = showPolyData(drillMesh, 'drill candidate', color=[1,0,0], visible=False, parent=getDebugFolder())
            drill.actor.SetUserTransform(drillFrame)
            om.addToObjectModel(drill, parentObj=getDebugFolder())
dataset/ETHPy150Open RobotLocomotion/director/src/python/director/segmentation.py/sortFittedDrills/swapped operands of `-`