human
Program to find Circumcenter of a Triangle | 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 on the bisector.
c = - bx + ay.
Returns the intersection point of two lines.
The lines are parallel . This is simplified by returning a pair of ( 10.0 ) * * 19.
Line PQ is represented as ax + by = c.
Line QR is represented as ex + fy = g.
Converting lines PQ and QR to perpendicular vbisectors . After this , L = ax + by = c M = ex + fy = g.
The point of intersection of L and M gives the circumcenter.
Driver code ."
How can the above be solved in Python?
 ... What is a code to program to find Circumcenter of a Triangle and the other steps required?
assistant
#Here is code to program to find Circumcenter of a Triangle and the other steps required.
 def lineFromPoints ( P , Q , a , b , c ) :
	a = Q [ 1 ] - P [ 1 ]
	b = P [ 0 ] - Q [ 0 ]
	c = a * ( P [ 0 ] ) + b * ( P [ 1 ] )
	return a , b , c
def perpendicularBisectorFromLine ( P , Q , a , b , c ) :
	mid_point = [ ( P [ 0 ] + Q [ 0 ] ) // 2 , ( P [ 1 ] + Q [ 1 ] ) // 2 ]
	c = - b * ( mid_point [ 0 ] ) + a * ( mid_point [ 1 ] )
	temp = a
	a = - b
	b = temp
	return a , b , c
def lineLineIntersection ( a1 , b1 , c1 , a2 , b2 , c2 ) :
	determinant = a1 * b2 - a2 * b1
	if ( determinant == 0 ) :
		return [ ( 10.0 ) ** 19 , ( 10.0 ) ** 19 ]
	else :
		x = ( b2 * c1 - b1 * c2 ) // determinant
		y = ( a1 * c2 - a2 * c1 ) // determinant
		return [ x , y ]
def findCircumCenter ( P , Q , R ) :
	a , b , c = 0.0 , 0.0 , 0.0
	a , b , c = lineFromPoints ( P , Q , a , b , c )
	e , f , g = 0.0 , 0.0 , 0.0
	e , f , g = lineFromPoints ( Q , R , e , f , g )
	a , b , c = perpendicularBisectorFromLine ( P , Q , a , b , c )
	e , f , g = perpendicularBisectorFromLine ( Q , R , e , f , g )
	circumcenter = lineLineIntersection ( a , b , c , e , f , g )
	if ( circumcenter [ 0 ] == ( 10.0 ) ** 19 and circumcenter [ 1 ] == ( 10.0 ) ** 19 ) :
		print ( " The ▁ two ▁ perpendicular ▁ bisectors ▁ found ▁ come ▁ parallel " )
		print ( " Thus , ▁ the ▁ given ▁ points ▁ do ▁ not ▁ form ▁ a ▁ triangle ▁ and ▁ are ▁ collinear " )
	else :
		print ( " The ▁ circumcenter ▁ of ▁ the ▁ triangle ▁ PQR ▁ is : ▁ " , end = " " )
		print ( " ( " , circumcenter [ 0 ] , " , " , circumcenter [ 1 ] , " ) " )
if __name__ == ' _ _ main _ _ ' :
	P = [ 6 , 0 ]
	Q = [ 0 , 0 ]
	R = [ 0 , 8 ]
	findCircumCenter ( P , Q , R )