void ensureTriangleOrder ( List < Point2D_I32 > contour ) { Element < Corner > e = list . getHead ( ) ; Corner a = e . object ; e = e . next ; Corner b = e . object ; e = e . next ; Corner c = e . object ; int distB = CircularIndex . distanceP ( a . index , b . index , contour . size ( ) ) ; int distC = CircularIndex . distanceP ( a . index , c . index , contour . size ( ) ) ; if ( distB > distC ) { list . reset ( ) ; list . pushTail ( a ) ; list . pushTail ( c ) ; list . pushTail ( b ) ; } }
Make sure the next corner after the head is the closest one to the head