Equation to find a point perpendicular with from an angle

121 Views Asked by At

Working on a fun side project and I have not done this math in a long time. Sorry the angle on the diagram is not very accurate. $d1 = d1$ angle, In the second diagram a1 = a1 angle.

enter image description here

enter image description here

I am trying to figure out an equation or steps for an equation (will be programming these in JavaScript).

Knowing only $P1, P2$ and $P3$, I need to find the $x,y$ coordinates of $P4$.

So far I have $d1 = \arctan\left(\frac{m2 - m1}{1 + m1*m2} \right)$

And I am now stuck trying to get $P4$ now. It has been a long time since I did equations like this and blanking on moving them around as needed.

1

There are 1 best solutions below

4
On BEST ANSWER

Let $s_{ij}$ denote the distance from $P_i$ to $P_j$.

The unit direction vector from $P_2$ to $P_3$ is $$ \vec{v}_{23}=\left\langle\frac{x_3-x_2}{s_{23}},\frac{y_3-y_2}{s_{23}}\right\rangle$$ where $s_{23}=\sqrt{(x_3-x_2)^2+(y_3-y_2)^2}$ the distance from $P_2$ to $P_3$.

Since $\vec{P_3P_4}\perp\vec{P_2P_3}$ the unit vector from $P_3$ to $P_4$ is

$$ \vec{v}_{34}=\left\langle\frac{y_3-y_2}{s_{23}},-\frac{x_3-x_2}{s_{23}}\right\rangle$$

or its negative (since the dot-product $\vec{v}_{34}\cdot\vec{v}_{23}=0 $). The vector equation of the line containing $P_3$ and $P_4$ is

$$ P=P_3+\vec{v}_{34}s $$

Since the distance from $P_3$ to $P_4$ is $s=s_{34}=s_{23}\tan(d_1)$ then

\begin{eqnarray} P_4&=&P_3\pm\vec{v}_{34}s_{23}\tan(d_1) \end{eqnarray}

Assuming that $P_4$ is on the same side of the line through $P_2$ and $P_3$ as is $P_1$, that will determine whether to use the plus or minus sign in the last equation.