Deep Learning - SG segmentation/FCN-DenseNet inference/libs/ConcaveHull - ars.py
def SortByAngle(kNearestPoints, currentPoint, prevPoint):
    ''' Sorts the k nearest points given by angle '''
    angles = np.zeros(kNearestPoints.shape[0])
    i = 0
    for NearestPoint in kNearestPoints:
        # calculate the angle
        angle = np.arctan2(NearestPoint[1]-currentPoint[1],
                NearestPoint[0]-currentPoint[0]) - \
                np.arctan2(prevPoint[1]-currentPoint[1],
                prevPoint[0]-currentPoint[0])
        angle = np.rad2deg(angle)
        # only positive angles
        angle = np.mod(angle+360,360)
        #print NearestPoint[0], NearestPoint[1], angle
        angles[i] = angle
        i=i+1
    return kNearestPoints[np.argsort(angles)]
 Sorts the k nearest points given by angle 
Sorts the k nearest points given by angle
Sorts the k nearest points given by angle
def SortByAngle(kNearestPoints, currentPoint, prevPoint):
    angles = np.zeros(kNearestPoints.shape[0])
    i = 0
    for NearestPoint in kNearestPoints:
        angle = np.arctan2(NearestPoint[1]-currentPoint[1],
                NearestPoint[0]-currentPoint[0]) - \
                np.arctan2(prevPoint[1]-currentPoint[1],
                prevPoint[0]-currentPoint[0])
        angle = np.rad2deg(angle)
        angle = np.mod(angle+360,360)
        angles[i] = angle
        i=i+1
    return kNearestPoints[np.argsort(angles)]
def SortByAngle ( kNearestPoints , currentPoint , prevPoint ) : angles = np . zeros ( kNearestPoints . shape [ 0 ] ) i = 0 for NearestPoint in kNearestPoints : angle = np . arctan2 ( NearestPoint [ 1 ] - currentPoint [ 1 ] , NearestPoint [ 0 ] - currentPoint [ 0 ] ) - np . arctan2 ( prevPoint [ 1 ] - currentPoint [ 1 ] , prevPoint [ 0 ] - currentPoint [ 0 ] ) angle = np . rad2deg ( angle ) angle = np . mod ( angle + 360 , 360 ) angles [ i ] = angle i = i + 1 return kNearestPoints [ np . argsort ( angles ) ]
Sorts the k nearest points given by angle
Sorts the k nearest points given by angle
''' Sorts the k nearest points given by angle ''' # calculate the angle # only positive angles #print NearestPoint[0], NearestPoint[1], angle
kNearestPoints
currentPoint
prevPoint