[Math] Rotate a line around origin to pass through a given point, how to find the rotate angle

analytic geometrygeometryrotations

A given coefficients line :
$$Ax + By + C = 0$$
I wish it rotate around the origin $O(0,0)$ and pass through a given point $P(p_x, p_y)$, how to find the rotate angle?
Of course the distance of point P to $O$ is greater than the distance point O to the line $Ax+By+C=0$ or it will have no solution.
The result can be have two angle.

Best Answer

Distance of line $L_1: Ax+By+C=0$ to origin is $R=\dfrac C{\sqrt{A^2+B^2}}$.

Hence $L_1$ is tangent to the circle $C_1: x^2+y^2=R^2$.

Rotating the line such that it passes through $P(h,k)$ (say) is equivalent to finding a tangent to the same circle that passes through $P$.

The equation of any line which is a tangent to the circle $C_1$ is given by $r=\dfrac R{\cos(\theta-\beta)}\tag{1}$.

The polar coordinates for $P$ are $(r,\theta)=(\sqrt{h^2+k^2}, \arctan\frac kh)\tag{2}$

Putting $(2)$ in $(1)$ gives $$\beta=\arctan\left(\frac kh\right)-\arccos\left(\frac R{\sqrt{h^2+k^2}}\right)\tag{3}$$

Substituting $(3)$ in $(1)$ gives the equation of the rotated line passing through $P$.