# Calculate a point on the line at a specific distance .

I have two points which make a line $l$ , lets say $(x_1,y_1) , (x_2,y_2)$ . I want a new point $(x_3,y_3)$ on the line $l$ at a distance $d$ from $(x_2,y_2)$ in the direction away from $(x_1,y_1)$ . How should i do this in one or two equation .

A point $(x,y)$ is on the line between $(x_1,y_1)$ and $(x_2,y_2)$ if and only if, for some $t\in\mathbb{R}$, $$(x,y)=t(x_1,y_1)+(1-t)(x_2,y_2)=(tx_1+(1-t)x_2,ty_1+(1-t)y_2)$$ You need to solve \begin{align*}d&=\|(x_2,y_2)-(tx_1+(1-t)x_2,ty_1+(1-t)y_2)\|=\sqrt{(tx_2-tx_1)^2+(ty_2-ty_1)^2}\\ &=\sqrt{t^2}\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\hspace{5pt}\Rightarrow\hspace{5pt} |t|=\frac{d}{\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}}\end{align*} You will have two values of $t$. For $t>0$ this point will be in the direction to $(x_1,y_1)$ and for $t<0$ it will be in the direction away from $(x_1,y_1)$.

Any point $p$ on your line can be written as $$p = (x_1, y_1) + \lambda \cdot (x_2 - x_1, y_2 - y_1)$$ for some $\lambda \in \mathbb R$, as these points form a line on which $(x_1, y_1)$ (corresponding to $\lambda = 0$) and $(x_2, y_2)$ (with $\lambda = 1$) lie.

A point lies on the same side of $(x_1, y_1)$ as $(x_2, y_2)$ when $\lambda > 0$, and "behind" $(x_2, y_2)$ if $\lambda > 1$. The distance of a point on $l$ to $(x_2, y_2)$ is given by \begin{align*} d^2 &= \bigl((1-\lambda)x_1 + \lambda x_2 - x_2\bigr)^2 + \bigl((1-\lambda)y_1 + \lambda y_2 - y_2\bigr)^2\\ &= (1-\lambda)^2(x_1 - x_2)^2 + (1-\lambda)^2(y_1 - y_2)^2\\ \iff d &= \left|1-\lambda\right| \cdot \bigl((x_1-x_2)^2 + (y_1-y_2)^2\bigr)^{1/2} \end{align*} So we want a $\lambda > 1$ (that is $|1-\lambda| = \lambda - 1$) at distance $d$, giving $$\lambda = 1 + \frac d{\bigl((x_1-x_2)^2 + (y_1-y_2)^2\bigr)^{1/2}}$$

$(x_3,y_3)\in l$

The points must be collinear so they form a triangle with surface area $0$ so

$$x_1(y_2-y_3)+x_2(y_3-y_1)+x_3(y_1-y_2)=0$$ $$d=\sqrt{(x_3-x_2)+(y_3-y_2)}$$

Since these points are co-linear, you have $\begin{bmatrix} x_1 & y_1 & 1 \\ x_2 & y_2 & 1 \\ x_3 & y_3 & 1 \\ \end{bmatrix} = 0$. This is one of your equation.

Now calculate the slope of your line and call it $\theta$ i.e. $\tan^{-1} \frac{y_2 - y_1}{x_2 - x_1}$. Point $(x_3, y_3)$ is $d$ distance away from one of the points (assuming $(x_2, y_2)$), you can calculate its coordinate by the following equation. $$x_3 = x_2 + d \sin \theta \\ y_3 = y_2 + d \cos \theta$$ Another useful equation is, $$\begin{equation} \frac{(y_3 - y_2)}{\sin \theta} = d \end{equation}$$ If your problem is to express this point in terms of $l$ and $d$ and not in terms of $x_1, y_1 ...$. You probably need one more equation for length of the line. There is some more work left to do i.e. to eliminate variables.

PS: See this question here