Find the angle between tangents drawn from a given external point to a Circle | Python 3 program for the above approach ; 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
import math NEW_LINE def point_distance ( x1 , y1 , x2 , y2 ) : NEW_LINE INDENT p = ( x2 - x1 ) NEW_LINE q = ( y2 - y1 ) NEW_LINE distance = math . sqrt ( p * p + q * q ) NEW_LINE return distance NEW_LINE DEDENT def tangentAngle ( x1 , y1 , x2 , y2 , radius ) : NEW_LINE INDENT distance = point_distance ( x1 , y1 , x2 , y2 ) NEW_LINE if ( radius / distance > 1 or radius / distance < - 1 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT result = 2 * math . asin ( radius / distance ) * 180 / 3.1415 NEW_LINE print ( result , " ▁ degrees " ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT radius = 4 NEW_LINE x1 = 7 NEW_LINE y1 = 12 NEW_LINE x2 = 3 NEW_LINE y2 = 4 NEW_LINE tangentAngle ( x1 , y1 , x2 , y2 , radius ) NEW_LINE DEDENT