protected double computeSegmentEnergy ( GrowQueue_I32 corners , int cornerA , int cornerB ) { int indexA = corners . get ( cornerA ) ; int indexB = corners . get ( cornerB ) ; if ( indexA == indexB ) { return 100000.0 ; } Point2D_I32 a = contour . get ( indexA ) ; Point2D_I32 b = contour . get ( indexB ) ; line . p . x = a . x ; line . p . y = a . y ; line . slope . set ( b . x - a . x , b . y - a . y ) ; double total = 0 ; int length = circularDistance ( indexA , indexB ) ; for ( int k = 1 ; k < length ; k ++ ) { Point2D_I32 c = getContour ( indexA + 1 + k ) ; point . set ( c . x , c . y ) ; total += Distance2D_F64 . distanceSq ( line , point ) ; } return ( total + splitPenalty ) / a . distance2 ( b ) ; }
Computes the energy for a segment defined by the two corner indexes