[Math] Coordinate Geometry finding x and y

analytic geometrytrigonometry

How would I rearrange this equation to find $x_3$ and $y_3$

$$\tan\ \alpha =\frac{\sqrt{(x_3-x_2)^2+(y_3-y_2)^2}}{ \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}}$$

EDIT: So basically what I want to do is that I have two points x1y1 and x2y2. I can draw a line between these points, I want to shift/rotate the line by angle $\alpha$ using x1y1 as origin of rotation and then find the point on the end of the rotated line (x3y3).

This is for some angle corrections in a programming challenge where I have to operate a vehicle

Best Answer

Let $R = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\tan\alpha$, since everything in it is constant. Then your equation becomes: $$(x_3-x_2)^2+(y_3-y_2)^2 = R^2$$ I.e., it is the equation of a circle with center $(x_2, y_2)$ of radius $R$. The sum $x_3+y_3$ is not constant on that circle, so no, you cannot solve for a particular value for it. The best you can say is that $$x_2+y_2 - R\sqrt 2 \le x_3+ y_3 \le x_2+y_2 + R\sqrt 2$$ but every value inbetween is taken on by some point on the circle.

Edit: for your actual problem, this just applying the rotation matrix for the angle $\alpha$ to the vector $(x_2 - x_1, y_2 - y_1)$, then adding $(x_1, y_1)$ back in again:

$$\begin{bmatrix}x_3\\y_3\end{bmatrix} = \begin{bmatrix}\cos \alpha &-\sin \alpha\\\sin \alpha & \cos \alpha\end{bmatrix}\begin{bmatrix}x_2 - x_1\\y_2 - y_1\end{bmatrix}+\begin{bmatrix}x_1\\y_1\end{bmatrix}$$ (for a counter-clockwise rotation when $\alpha > 0$).

Related Question