Looking for a formula to find the angle to a point that creates two perpendicular lines to two other points.

59 Views Asked by At

I've been trying to create a formula that finds the angle with respect to the x-axis to a point from some origin point. This new point must create lines to both the origin point and to some other point that must be perpendicular.

Diagram to show what I'm talking about

You can see that the new point should lie on the circle defined by some radius r in the formula, and that the line from origin to new point is perpendicular to the line from new point to other point.

I understand that there will be two unique solutions and what I'm looking for is a formula that finds any unique solution. Thanks for reading and helping :)

1

There are 1 best solutions below

1
On BEST ANSWER

enter image description here

In the diagram above, $\theta_1$ and $\theta_2$ are the angles from $B$ and $B'$ respectively, to the x-axis. Let $d$ be the distance from $O$ to $A$, i.e. $d = \sqrt{p^2+q^2}$; and let $\alpha$ be the angle between $OA$ and the x-axis, so clearly $\alpha = \tan^{-1} \left(\frac{q}{p}\right)$.

Then $$\begin{align} \theta_1 &= \angle AOB + \alpha \\ &= \cos^{-1} \left( \frac{r}{d} \right) + \tan^{-1} \left( \frac{q}{p} \right) \\ &= \cos^{-1} \left( \frac{r}{\sqrt{p^2+q^2}} \right) + \tan^{-1} \left( \frac{q}{p} \right) \\ \end{align}$$

Similarly, $$\begin{align} \theta_2 &= \angle AOB' - \alpha \\ &= \cos^{-1} \left( \frac{r}{d} \right) - \tan^{-1} \left( \frac{q}{p} \right) \\ &= \cos^{-1} \left( \frac{r}{\sqrt{p^2+q^2}} \right) - \tan^{-1} \left( \frac{q}{p} \right) \\ \end{align}$$