Find value of x in distance formula

1.8k Views Asked by At

I am trying to find new end coordinates on an existing line. I am working on on Excel and finding it hard to find value of x by using distance formula where I know the distance.

I have a line with start points $(x_1,y_1)$ and end points $(x_2,y_2)$. I know the distance of the line. I am trying to find out pair of new points where $(x_1,y_1)$ is the still the start point and $(x,y)$ are the new points based on reduced distance on the same line.

I am calculating the equation of line $y = mx + c$ where m is the slope and $c$ is the y-intercept and $m$ is calculated by $m = \frac{y_2-y_1 }{ x_2-x_1}$

Since I know the distance I am trying to compute new points $x$ and $y$ in the distance formula - $distance=\sqrt{(x-x_1)^2+(y-y_1)^2}$ where I compute $y$ value.

I am trying to write a macro where in I can calculate $x$ value, but I am having trouble trying to figure out how to compute $x$ by substituting distance and $y$ in the above formula.

Any suggestions on how to complete this will be really appreciated.

Thanks in advance

1

There are 1 best solutions below

6
On BEST ANSWER

Letting $d$ be distance, you have $$d=\sqrt{(x-x_1)^2+(y-y_1)^2} \\y=mx+c\\d=\sqrt{(x-x_1)^2+(mx+c-y_1)^2}\\ d^2=(m+1)x^2+2(cm-my_1-x_1)x+x_1^2+(c-y_1)^2$$ which is a quadratic in $x$ that you can feed to the quadratic formula. There will be two solutions, one each side of your point $(x_1,y_1)$ If you want the solution in the direction of $x_2$ and $x_2 \gt x_1$ you want the sign of $m+1$