Given a line with first end point P(x1,y1) another end point is unknown, intersect with a circle that located at origin with radius R at only one point(tangent) T(x2,y2). An
You can find direction of vector DX if you rotate vector DO by angle alpha (angle alpha is found as asin(len(OX) / len(DO)), which is simply arcsinus of radius over hypotenuse)
You can find the length of vector DX trivially as following: sqrt(len(DO)*len(DO) - len(OX)*len(OX))
Given the direction and length of vector DX, you can find the value of point X. One approach would be to normalize DX and multiply it by the length of it.
auto dist = D.Distance(O); auto side = sqrt(dist*dist - rad*rad) auto line = Vector2D(D, O); line.Rotate(asin(rad / dist)); //get the direction line.Normalize(); //set length to 1 line*=side; //we have the direction, now get length Point2D X = D + line;
P.S. Note that there is also a second tangent, which is found by rotating DO by minus alpha
