Talon Mcbride

2022-07-17

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 $\left({x}_{1},{y}_{1}\right),\left({x}_{2},{y}_{2}\right)$ is given to us.Now we need to find another point which lies at distance d from $\left({x}_{2},{y}_{2}\right)$ , making an angle θ in such a way that if we go from $\left({x}_{1},{y}_{1}\right)$ to $\left({x}_{2},{y}_{2}\right)$ and then to $\left({x}_{3},{y}_{3}\right)$ it forms counterclockwise direction.
Note : $p1=\left({x}_{1},{y}_{1}\right),p2=\left({x}_{2},{y}_{2}\right),p3=\left({x}_{3},{y}_{3}\right)$
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 shortapproach ?

Danica Ray

Expert

Let
${\stackrel{\to }{p}}_{1}=\left[\begin{array}{c}{x}_{1}\\ {y}_{1}\end{array}\right],\phantom{\rule{1em}{0ex}}{\stackrel{\to }{p}}_{2}=\left[\begin{array}{c}{x}_{2}\\ {y}_{2}\end{array}\right],\phantom{\rule{1em}{0ex}}{\stackrel{\to }{p}}_{3}=\left[\begin{array}{c}{x}_{3}\\ {y}_{3}\end{array}\right]$
Distance between ${\stackrel{\to }{p}}_{1}$ and ${\stackrel{\to }{p}}_{2}$ is r,
$r=‖{\stackrel{\to }{p}}_{2}-{\stackrel{\to }{p}}_{1}‖=\sqrt{\left({x}_{2}-{x}_{1}{\right)}^{2}+\left({y}_{2}-{y}_{1}{\right)}^{2}}$
Rotating a vector clockwise by $\phi$ around origin is
$\left[\begin{array}{c}{x}_{\text{new}}\\ {y}_{\text{new}}\end{array}\right]=\left[\begin{array}{cc}\mathrm{cos}\phi & \mathrm{sin}\phi \\ -\mathrm{sin}\phi & \mathrm{cos}\phi \end{array}\right]\left[\begin{array}{c}{x}_{\text{old}}\\ {y}_{\text{old}}\end{array}\right]$
For counterclockwise rotation, use the transposed matrix (change both $\mathrm{sin}\phi$ signs).
It seems to me we want to take the vector from ${\stackrel{\to }{p}}_{2}$ to ${\stackrel{\to }{p}}_{1}$ (i.e. ${\stackrel{\to }{p}}_{1}-{\stackrel{\to }{p}}_{2}$), scale it by d/r (so it will have Euclidean length d), and then rotate it around ${\stackrel{\to }{p}}_{2}$ clockwise by $\theta$. (The order of scaling and rotating doesn't matter, of course.)
Using
${\mathbf{R}}_{\theta }=\left[\begin{array}{cc}\mathrm{cos}\theta & \mathrm{sin}\theta \\ -\mathrm{sin}\theta & \mathrm{cos}\theta \end{array}\right]$
in vector notation this would be
${\stackrel{\to }{p}}_{3}={\stackrel{\to }{p}}_{2}+\frac{d}{r}{\mathbf{R}}_{\theta }\left({\stackrel{\to }{p}}_{1}-{\stackrel{\to }{p}}_{2}\right)$
i.e.
${\stackrel{\to }{p}}_{3}={\stackrel{\to }{p}}_{2}+\frac{d}{\sqrt{\left({\stackrel{\to }{p}}_{1}-{\stackrel{\to }{p}}_{2}\right)\cdot \left({\stackrel{\to }{p}}_{1}-{\stackrel{\to }{p}}_{2}\right)}}{\mathbf{R}}_{\theta }\left({\stackrel{\to }{p}}_{1}-{\stackrel{\to }{p}}_{2}\right)$
and the Cartesian coordinate notation is

Do you have a similar question?