public static double circleRadiusSq ( Point2D_F64 x0 , Point2D_F64 x1 , Point2D_F64 x2 ) { // points that lie on line a and b double xa = ( x0 . x + x1 . x ) / 2.0 ; double ya = ( x0 . y + x1 . y ) / 2.0 ; double xb = ( x1 . x + x2 . x ) / 2.0 ; double yb = ( x1 . y + x2 . y ) / 2.0 ; // slopes of lines a and b double m2 = x0 . x - x1 . x ; double m1 = x1 . y - x0 . y ; double n2 = x2 . x - x1 . x ; double n1 = x1 . y - x2 . y ; // find the intersection of the lines double bottom = m2 * n1 - n2 * m1 ; if ( bottom == 0 ) return Double . NaN ; double alpha = ( - m2 * ( xb - xa ) + m1 * ( yb - ya ) ) / bottom ; double dx = xb + n1 * alpha - x0 . x ; double dy = yb + n2 * alpha - x0 . y ; return dx * dx + dy * dy ; }
Radius squares of the circle that passes through these three points .