Find intermediate points to avoid circle obstacle in path I have two points $P_1$ and $P_2$, as well as a circle with radius $r$ centered at $C$. All three points are at arbitrary positions.
I want to go from $P_1$ to $P_2$ without crossing through the circle.
For that reason, another point $P_3$ is needed as an intermediary. This can be any of two points (shown in the image as $P_3$ and $P_4$) How do I obtain their coordinates? I attach a picture to aid in the explanation.

Edit 1: I suppose it is obtained as the intersection between the tangents from $P_1$ and $P_2$ but am not entirely sure on how to.
Edit 2: Assume the circle always interferes with the path, even if slightly.
Edit 3: The radius $r$ of the circle is given.
 A: After trying for a while, I found a possible solution. I leave it here in case it helps anyone :)
Getting tangent points from $P_1$ to circle.
To aid in the process, let's center the circle to the origin (subtract coordinates from all points).
As shown in the image below, a right angle triangle can be formed with the vertices of the circle center, the point ($P_1$) and the tangent point ($Q$).


*

*Using simple trigonometry we can find the value of $\theta = \arccos\left(\frac{r}{d}\right)$, where $d$ is the distance between the center and $P_1$.


*Furthermoe, the angle $\phi$ can be found using the components of $P_1$, such that $\phi = \arctan\left(\frac{y_1}{x_1}\right)$.


*The points are then generated:
$$Q_1 = \left( \frac{x_1}{|x_1|}r\cos(\theta + \phi), \frac{x_1}{|x_1|}r\sin(\theta + \phi) \right)$$
$$Q_2 = \left( \frac{x_1}{|x_1|}r\cos(\theta - \phi), \frac{x_1}{|x_1|}r\sin(\theta - \phi) \right)$$


*After restoring the coordinate system, the equations of lines $Q_1P_1$ and $Q_2P_1$ can be found.
Further steps
The problem is then reduced to: find the intersection points of both pairs of tangent lines.
The tricky part might be finding out which pairs to compare. Perhaps there is an even better solution for this second phase.
A: Building on edvilme’s approach, we can turn this problem into a system of equations. This one is just for P3, but you can mirror the approach for P4. $x_{13}$, $y_{13}$, $y_{23}$, and $x_{23}$ are the coordinates of the points where the tangent lines intersect the circle, which are not given, and $x_3$ and $y_3$ are the coordinates of P3. Here is the system of equations:$$x_{13}^2+y_{13}^2=r^2$$
$$x_{23}^2+y_{23}^2=r^2$$
$$(x_{13}-x_1)^2+(y_{13}-y_1)^2=x_1^2+y_1^2-r$$
$$(x_{23}-x_2)^2+(y_{23}-y_2)^2=x_2^2+y_2^2-r$$
$$y_1+(x_3-x_1)(\frac{y_1-y_{13}}{x_1-x_{13}})=y_2+(x_3-x_2)(\frac{y_{23}-y_2}{x_{23}-x_2})$$
$$y_3=y_1+(x_3-x_1)(\frac{y_1-y_{13}}{x_1-x_{13}})$$
Some easy mental math for you :).
