# How to find the third point at a given distance angle from a line segment in a plane?

Suppose i have a plane and a line segment with end points $$(x_1,y_1),(x_2,y_2)$$ is given to us.Now we need to find another point which lies at distance $$d$$ from $$(x_2,y_2)$$ , making an angle $$θ$$ in such a way that if we go from $$(x_1,y_1)$$ to $$(x_2,y_2)$$ and then to $$(x_3,y_3)$$ it forms counterclockwise direction.

Note : $$p1 = (x_1,y_1) , p2 = (x_2,y_2) , p3 = (x_3,y_3)$$ (please see the figure below)

My approach : we can use dot product and it will give us equation of for $$Ax + By = C$$ where $$A,B,C$$ are constants.Then we can use information given by $$d$$. After solving two equations we will get two points , one in clockwise direction and other in counterclockwise direction . We can get out desired point using cross product (it will be negative for the point we want and positive for the other point).

You see that my approach is very lengthy .Is there any short and elegant approach ?

figure

• Why not simply rotate the line segment and then adjust its length?
– amd
May 20, 2020 at 19:27
• @amd That is nice idea . Thanks May 21, 2020 at 4:49

Let $$\vec{p}_1 = \left[\begin{matrix} x_1 \\ y_1 \end{matrix}\right], \quad \vec{p}_2 = \left[\begin{matrix} x_2 \\ y_2 \end{matrix}\right], \quad \vec{p}_3 = \left[\begin{matrix} x_3 \\ y_3 \end{matrix}\right]$$

Distance between $$\vec{p}_1$$ and $$\vec{p}_2$$ is $$r$$, $$r = \left\lVert \vec{p}_2 - \vec{p}_1 \right\rVert = \sqrt{ (x_2 - x_1)^2 + (y_2 - y_1)^2 }$$

Rotating a vector clockwise by $$\varphi$$ around origin is $$\left[\begin{matrix} x_\text{new} \\ y_\text{new} \end{matrix}\right] = \left[\begin{matrix} \cos\varphi & \sin\varphi \\ -\sin\varphi & \cos\varphi \end{matrix}\right] \left[\begin{matrix} x_\text{old} \\ y_\text{old} \end{matrix}\right]$$ For counterclockwise rotation, use the transposed matrix (change both $$\sin\varphi$$ signs).

It seems to me we want to take the vector from $$\vec{p}_2$$ to $$\vec{p}_1$$ (i.e. $$\vec{p}_1 - \vec{p}_2$$), scale it by $$d/r$$ (so it will have Euclidean length $$d$$), and then rotate it around $$\vec{p}_2$$ clockwise by $$\theta$$. (The order of scaling and rotating doesn't matter, of course.)

Using $$\mathbf{R}_\theta = \left[\begin{matrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{matrix}\right]$$ in vector notation this would be $$\vec{p}_3 = \vec{p}_2 + \frac{d}{r}\mathbf{R}_\theta\Bigr(\vec{p}_1 - \vec{p}_2\Bigr)$$ i.e. $$\vec{p}_3 = \vec{p}_2 + \frac{d}{\sqrt{(\vec{p}_1 - \vec{p}_2)\cdot(\vec{p}_1 - \vec{p}_2)}} \mathbf{R}_\theta\Bigr(\vec{p}_1 - \vec{p}_2\Bigr)$$ and the Cartesian coordinate notation is \left\lbrace ~ \begin{aligned} x_3 &= x_2 + \frac{d (x_1-x_2)\cos\theta + d (y_1-y_2)\sin\theta}{\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2}} \\ y_3 &= y_2 + \frac{d (y_1-y_2)\cos\theta - d (x_1-x_2)\sin\theta}{\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2}} \\ \end{aligned} \right.

• I guess there should not be $z_1,z_2$ , since it's true for two dimension only May 21, 2020 at 6:29
• @Mike: You are absolutely right, thanks for pointing out the error!
– None
May 21, 2020 at 15:47