Finding a point along a line a certain distance away from another point!
Solution 1:
Another way, using vectors:
Let $\mathbf v = (x_1,y_1)-(x_0,y_0)$. Normalize this to $\mathbf u = \frac{\mathbf v}{||\mathbf v||}$.
The point along your line at a distance $d$ from $(x_0,y_0)$ is then $(x_0,y_0)+d\mathbf u$, if you want it in the direction of $(x_1,y_1)$, or $(x_0,y_0)-d\mathbf u$, if you want it in the opposite direction. One advantage of doing the calculation this way is that you won't run into a problem with division by zero in the case that $x_0 = x_1$.
Solution 2:
Let me explain the answer in a simple way.
Start point - $(x_0, y_0)$
End point - $(x_1, y_1)$
We need to find a point $(x_t, y_t)$ at a distance $d_t$ from start point towards end point.
The distance between Start and End point is given by $d = \sqrt{(x_1-x_0)^2+(y_1-y_0)^2}$
Let the ratio of distances, $t=d_t/d$
Then the point $(x_t, y_t) =(((1-t)x_0+tx_1), ((1-t)y_0+ty_1))$
When $0<t<1$, the point is on the line.
When $t<0$, the point is outside the line near to $(x_0,y_0)$.
When $t>1$, the point is outside the line near to $(x_1,y_1)$.
Solution 3:
You can very easily find it with trigonometry!!
Let's say Xa and Xb are the two points of your line, and D is the distance between them. And you are looking to find Xc which is D2 away from Xa (as the diagram bellow):
You can easily find D:
The formulas that you can find Xa, Xb, Xc, D and D2 are:
But SINa-b and SINa-c share the same the same corner, so they are equal:
Since you know the distance (D2) between Xa and Xc that you are looking for, you can easily solve the following:
In conclusion by solving the formula for D and the last one you are done. (You need one for the Y as well, just replace in the last one, X with Y )
Hope it helps!!