Equation of a normal to a Circle from a given point | Function to calculate the slope ; Store the coordinates the center of the circle ; If slope becomes infinity ; Stores the slope ; If slope is zero ; Return the result ; Function to find the equation of the normal to a circle from a given point ; Stores the slope of the normal ; If slope becomes infinity ; If slope is zero ; Otherwise , print the equation of the normal ; Given Input ; Function Call
function normal_slope ( a , b , x1 , y1 ) { var g = a / 2 ; var f = b / 2 ; if ( g - x1 == 0 ) return ( - 1 ) ; var slope = ( f - y1 ) / ( g - x1 ) ; if ( slope == 0 ) return ( - 2 ) ; return slope ; } function normal_equation ( a , b , x1 , y1 ) { var slope = normal_slope ( a , b , x1 , y1 ) ; if ( slope == - 1 ) { document . write ( " " + x1 ) ; } if ( slope == - 2 ) { document . write ( " " + y1 ) ; } if ( slope != - 1 && slope != - 2 ) { x1 *= - slope ; x1 += y1 ; if ( x1 > 0 ) document . write ( " " + slope + " " + x1 . toFixed ( 1 ) ) ; else document . write ( " " + slope + " " + x1 . toFixed ( 1 ) ) ; } } var a = 4 , b = 6 , c = 5 ; var x1 = 12 , y1 = 14 ; normal_equation ( a , b , x1 , y1 ) ;