# Find the ending coordinates of line if it is extended by a D distance

A line draw between $$(x_1,y_1)$$ to $$(x_2,y_2)$$. I need to find the ending point in which the line is extended by $$D$$ distance(or length). From the above image, $$(x_1,y_1)$$,$$(x_2,y_2)$$ and $$D$$ is known, I need to find $$(x_3,y_3)$$.

Welcome to MSE. One way to express the location of $$(x_3, y_3)$$ is as $$\langle x_2, y_2 \rangle + D \cdot \langle u, v \rangle$$, where $$\langle u, v\rangle$$ is the unit vector pointing in the direction of $$\langle x_2, y_2 \rangle - \langle x_1, y_1 \rangle$$

Define the unit vector from $$(x_1, y_1)$$ to $$(x_2, y_2)$$ as follows

$$v = \dfrac{ (x_2 - x_1, y_2 - y_1) }{L}$$

where $$L = \sqrt{ (x_2 - x_1)^2 + (y_2 - y_1)^2 }$$

Then

$$(x_3, y_3) = (x_1, y_1) + (L+D) v$$

or equivalently,

$$(x_3, y_3) = (x_2, y_2) + D v$$

• I have a small doubt, (𝑥3,𝑦3)=(𝑥1,𝑦1)+(𝐿+𝐷)𝑣=(𝑥2,𝑦2)+𝐷𝑣 in the above equation why do you put two assignmet symbol on same line. May 9, 2022 at 11:27
• Because they are equal to each other. May 9, 2022 at 11:48
• I'll edit the solution to make it clearer. May 9, 2022 at 12:23

The line through $$(x_1, y_1)$$ and $$(x_1, y_2)$$ can be written $$y= \frac{y_2-y_1}{x_2-x_2}(x- x_2)+ y_2$$.

The circle with center at $$(x_2, y_2)$$ and radius D can be written $$(x-x_2)^2+ (y-y_2)^2= D^2$$.

$$(x_3, y_3)$$, the endpoint of the line segment extended from $$(x_2, y_2)$$ by distance D is where that line and circle intersect so we must have $$(x_3- x_2)^2+ (\frac{y_2-y_1}{x_2-x_2}(x_3- x_2))^2= D^2$$.

Solve that quadratic equation for $$x_3$$ and then use the equation of the line to find $$y_3$$.

(That equation will have two roots. You want the one on the other side of $$x_2$$ from $$x_1$$.)