I have a circle around a given point, call this point $(x_1, y_1)$. I know the radius of the circle around this point. I also have a second point $(x_2, y_2)$, that is a distance away, outside the radius of the circle.
I need a algebraic way through code to calculate the heading (angle from vertical) needed to intersect the circle at $90^\circ$ to the center point (I.E. get the angle of the tangent intersecting line 2) around the point $(x_1, y_1)$ from the second point $(x_2, y_2)$
A bit of background: Essentially the two points are GPS coordinates on a 2D map, I need to know the target heading to intersect the circle in order to follow its path around the center point.
Additional info: P is the center of the circle, X is the arbitrary point, D is a known distance, R is the known radius, I need to find the tangent to the point X and the angle from North (straight up) to that tangent point from X.
The known info is R, D, Point X, Point P, and through math, the distance to wherever the tangent point is