private static Point findMidnormalPoint ( Point center , Point a , Point b , Rect area , int radius ) { if ( a . y == b . y ) { //top if ( a . y < center . y ) { return new Point ( ( a . x + b . x ) / 2 , center . y + radius ) ; } //bottom return new Point ( ( a . x + b . x ) / 2 , center . y - radius ) ; } if ( a . x == b . x ) { //left if ( a . x < center . x ) { return new Point ( center . x + radius , ( a . y + b . y ) / 2 ) ; } //right return new Point ( center . x - radius , ( a . y + b . y ) / 2 ) ; } //slope of line ab double abSlope = ( a . y - b . y ) / ( a . x - b . x * 1.0 ) ; //slope of midnormal double midnormalSlope = - 1.0 / abSlope ; double radian = Math . tan ( midnormalSlope ) ; int dy = ( int ) ( radius * Math . sin ( radian ) ) ; int dx = ( int ) ( radius * Math . cos ( radian ) ) ; Point point = new Point ( center . x + dx , center . y + dy ) ; if ( ! inArea ( point , area , 0 ) ) { point = new Point ( center . x - dx , center . y - dy ) ; } return point ; }
find the middle point of two intersect points in circle only one point will be correct