Here's a sketch of the problem:

_{1}and B

_{2}. We argue mainly for B

_{1}. The argument for B

_{2}is the same. We have assumed A is outside of the circle or else there are no solutions. (If you write code for this, you will need to check for this condition.)

Since AB

_{1}is tangent to the circle and B

_{1}C is the radius of the circle, angle AB

_{1}C is a right angle. The distances f and from A to C, say, d, may be calculated using the pythagorean theorem. Now, we draw the altitude of triangle AB

_{1}C to E. By similar triangles (ΔAB

_{1}C ~ ΔB

_{1}EC~ ΔAEB1) we determine that

and

and so, e = r

^{2}/d and a = f r/d. We let δ be the normalized direction vector from C to A, namely,

Then point E is given by E = C + e δ. Let δ

_{p}= (δ

_{y}, –δ

_{x}), or the clockwise 90° rotation of δ. Then points B

_{1}and B

_{2}are given by:

B

_{1}= E + a δ

_{p}

and

B

_{2}= E – a δ

_{p},

which are the desired points.