Find if a point lies inside , outside or on the circumcircle of three points A , B , C | Java program to find the points which lies inside , outside or on the circle ; Structure Pointer to store x and y coordinates ; Function to find the line given two points ; Function which converts the input line to its perpendicular bisector . It also inputs the points whose mid - point lies o on the bisector ; Find the mid point ; x coordinates ; y coordinates ; c = - bx + ay ; Assign the coefficient of a and b ; Returns the intersection point of two lines ; Find determinant ; Returns the intersection point of two lines ; Find determinant ; Function to find the point lies inside , outside or on the circle ; Store the coordinates radius of circumcircle ; Line PQ is represented as ax + by = c ; Line QR is represented as ex + fy = g ; Converting lines PQ and QR to perpendicular bisectors . After this , L = ax + by = c M = ex + fy = g ; The point of intersection of L and M gives r as the circumcenter ; Length of radius ; Distance between radius and the given point D ; Condition for point lies inside circumcircle ; Condition for point lies on circumcircle ; Condition for point lies outside circumcircle ; Driver Code ; Given Points ; Function call to find the point lies inside , outside or on the circle
class GFG { static class point { double x , y ; public point ( ) { } public point ( double x , double y ) { this . x = x ; this . y = y ; } } ; static void lineFromPoints ( point P , point Q , double a , double b , double c ) { a = Q . y - P . y ; b = P . x - Q . x ; c = a * ( P . x ) + b * ( P . y ) ; } static void perpenBisectorFromLine ( point P , point Q , double a , double b , double c ) { point mid_point = new point ( ) ; mid_point . x = ( P . x + Q . x ) / 2 ; mid_point . y = ( P . y + Q . y ) / 2 ; c = - b * ( mid_point . x ) + a * ( mid_point . y ) ; double temp = a ; a = - b ; b = temp ; } static double LineInterX ( double a1 , double b1 , double c1 , double a2 , double b2 , double c2 ) { double determ = a1 * b2 - a2 * b1 ; double x = ( b2 * c1 - b1 * c2 ) ; x /= determ ; return x ; } static double LineInterY ( double a1 , double b1 , double c1 , double a2 , double b2 , double c2 ) { double determ = a1 * b2 - a2 * b1 ; double y = ( a1 * c2 - a2 * c1 ) ; y /= determ ; return y ; } static void findPosition ( point P , point Q , point R , point D ) { point r = new point ( ) ; double a = 0 , b = 0 , c = 0 ; lineFromPoints ( P , Q , a , b , c ) ; double e = 0 , f = 0 , g = 0 ; lineFromPoints ( Q , R , e , f , g ) ; perpenBisectorFromLine ( P , Q , a , b , c ) ; perpenBisectorFromLine ( Q , R , e , f , g ) ; r . x = LineInterX ( a , b , c , e , f , g ) ; r . y = LineInterY ( a , b , c , e , f , g ) ; double q = ( r . x - P . x ) * ( r . x - P . x ) + ( r . y - P . y ) * ( r . y - P . y ) ; double dis = ( r . x - D . x ) * ( r . x - D . x ) + ( r . y - D . y ) * ( r . y - D . y ) ; if ( dis < q ) { System . out . print ( " Point ▁ ( " + D . x + " , ▁ " + D . y + " ) ▁ is ▁ inside ▁ " + " the ▁ circumcircle " ) ; } else if ( dis == q ) { System . out . print ( " Point ▁ ( " + D . x + " , ▁ " + D . y + " ) ▁ lies ▁ on ▁ the ▁ " + " circumcircle " ) ; } else { System . out . print ( " Point ▁ ( " + D . x + " , ▁ " + D . y + " ) ▁ lies ▁ outside " + " ▁ the ▁ circumcircle " ) ; } } public static void main ( String [ ] args ) { point A , B , C , D ; A = new point ( 2 , 8 ) ; B = new point ( 2 , 1 ) ; C = new point ( 4 , 5 ) ; D = new point ( 3 , 0 ) ; findPosition ( A , B , C , D ) ; } }