Distance between orthocenter and circumcenter of a right | Python3 program for the above approach ; Function to calculate Euclidean distance between the points p1 and p2 ; Stores x coordinates of both points ; Stores y coordinates of both points ; Return the Euclid distance using distance formula ; Function to find orthocenter of the right angled triangle ; Find the length of the three sides ; Orthocenter will be the vertex opposite to the largest side ; Function to find the circumcenter of right angle triangle ; Circumcenter will be located at center of hypotenuse ; If AB is the hypotenuse ; If BC is the hypotenuse ; If AC is the hypotenuse ; Function to find distance between orthocenter and circumcenter ; Find circumcenter ; Find orthocenter ; Find the distance between the orthocenter and circumcenter ; Print distance between orthocenter and circumcenter ; Given coordinates A , B , and C ; Function Call
import math NEW_LINE def distance ( p1 , p2 ) : NEW_LINE INDENT x1 , x2 = p1 [ 0 ] , p2 [ 0 ] NEW_LINE y1 , y2 = p1 [ 1 ] , p2 [ 1 ] NEW_LINE return int ( math . sqrt ( pow ( x2 - x1 , 2 ) + pow ( y2 - y1 , 2 ) ) ) NEW_LINE DEDENT def find_orthocenter ( A , B , C ) : NEW_LINE INDENT AB = distance ( A , B ) NEW_LINE BC = distance ( B , C ) NEW_LINE CA = distance ( C , A ) NEW_LINE if ( AB > BC and AB > CA ) : NEW_LINE INDENT return C NEW_LINE DEDENT if ( BC > AB and BC > CA ) : NEW_LINE INDENT return A NEW_LINE DEDENT return B NEW_LINE DEDENT def find_circumcenter ( A , B , C ) : NEW_LINE INDENT AB = distance ( A , B ) NEW_LINE BC = distance ( B , C ) NEW_LINE CA = distance ( C , A ) NEW_LINE if ( AB > BC and AB > CA ) : NEW_LINE INDENT return ( ( A [ 0 ] + B [ 0 ] ) // 2 , ( A [ 1 ] + B [ 1 ] ) // 2 ) NEW_LINE DEDENT if ( BC > AB and BC > CA ) : NEW_LINE INDENT return ( ( B [ 0 ] + C [ 0 ] ) // 2 , ( B [ 1 ] + C [ 1 ] ) // 2 ) NEW_LINE DEDENT return ( ( C [ 0 ] + A [ 0 ] ) // 2 , ( C [ 1 ] + A [ 1 ] ) // 2 ) NEW_LINE DEDENT def findDistance ( A , B , C ) : NEW_LINE INDENT circumcenter = find_circumcenter ( A , B , C ) NEW_LINE orthocenter = find_orthocenter ( A , B , C ) NEW_LINE distance_between = distance ( circumcenter , orthocenter ) NEW_LINE print ( distance_between ) NEW_LINE DEDENT A = [ 0 , 0 ] NEW_LINE B = [ 6 , 0 ] NEW_LINE C = [ 0 , 8 ] NEW_LINE findDistance ( A , B , C ) NEW_LINE