If I have a point B tangent to a circle with known radius r, and a point D outside the circle, how do I find the intersection of tangent lines through B and D?
If the only known values are the blue ones as shown in the sketch, how do I find point E? I guess I'm missing the math background to combine similar examples with other known values to come to a solution.
By running some more synthetic geometry first, you can apply the law of cosines on triangle BCD to express CD, then use in Pythagoras' theorem for triangle CDF to find the length d of of DF. Then, apply the law of cosines to the triangle BDE to find the length e of EF, where e = DE - d. Since EB = EF = e you just have to make the vector AB unit first and then multiply by e to find vector BE. After that just add the coordinates of B to BE.
The point H is the other point on the line AB such that the line DH is the other tangent to the circle.
import numpy as np
import math
'''
input A, B, D, r
'''
A = [ 0,-4]
B = [-1, 1]
D = [ 5, 0]
r = 2
A = [ 5.49, -8.12]
B = [ 1.24, 1.82]
D = [ 15.95, -1.12]
r = 3
A = np.array(A)
B = np.array(B)
D = np.array(D)
AB = B - A
l_AB = math.sqrt(AB[0]**2 + AB[1]**2)
AB = AB / l_AB
BD = D - B
l_BD = math.sqrt(BD[0]**2 + BD[1]**2)
cos_alpha = (-AB[0]*BD[0] - AB[1]*BD[1]) / l_BD
sin_alpha = math.sqrt(1 - cos_alpha**2)
d = math.sqrt( l_BD**2 - 2*r*l_BD*sin_alpha )
e = (l_BD**2 - d**2) / (2*d - 2*l_BD*cos_alpha)
E = B + e*AB
h = (l_BD**2 - d**2) / (2*d + 2*l_BD*cos_alpha)
H = B - h*AB
AB_perp = [AB[1], -AB[0]]
AB_perp = np.array(AB_perp)
C = B + r*AB_perp
CE = E - C
l2_CE = CE[0]**2 + CE[1]**2
G = C + (r**2 / l2_CE)*CE
F = B + 2*(G - B)
print('E =', E)
print('H =', H)
print('C =', C)
print('G =', G)
print('F =', F)