Find the angle between tangents drawn from a given external point to a Circle | Function to find the distance between center and the exterior point ; Find the difference between the x and y coordinates ; Using the distance formula ; Function to find the angle between the pair of tangents drawn from the point ( X2 , Y2 ) to the circle . ; Calculate the distance between the center and exterior point ; Invalid Case ; Find the angle using the formula ; Print the resultant angle ; Driver code
function point_distance ( x1 , y1 , x2 , y2 ) { var p = ( x2 - x1 ) ; var q = ( y2 - y1 ) ; var distance = Math . sqrt ( p * p + q * q ) ; return distance ; } function tangentAngle ( x1 , y1 , x2 , y2 , radius ) { var distance = point_distance ( x1 , y1 , x2 , y2 ) ; if ( radius / distance > 1 radius / distance < - 1 ) { document . write ( - 1 + " " ) ; } var result = 2 * Math . asin ( radius / distance ) * 180 / 3.1415 ; document . write ( result . toFixed ( 4 ) + " " ) ; } var radius = 4 ; var x1 = 7 , y1 = 12 ; var x2 = 3 , y2 = 4 ; tangentAngle ( x1 , y1 , x2 , y2 , radius ) ;