I am looking to find the $ x_1, y_1 $ coordinate that is distance $d$ from a starting point of $x_0, y_0$ coordinate as traveled along a line ($y=mx+b$)

I was going to ask this question here, but I found that it had already been asked: Finding a point along a line a certain distance away from another point!

The answer looks simple, but it uses vector based math. I think I did some of that in school, but I have long forgotten how to do it, and some googling did not help.

So I thought I would ask someone to explain that answer by walking through some real numbers.

Say I have a starting point of $3_0,4_0$ and an end point of $9_2, 13_2$. If I travel a distance of $3$, what is my $x_1, y_1$ coordinates? (Note that these numbers are totally made up for this question, but are representative of the problems I am trying to solve.)

If someone could walk me through the using the equations in that answer I would be grateful.

NOTE: In case anyone is interested why I need this, I am doing a video game and I am trying to calculate the movement of a particle along a given trajectory in between each draw cycle.


1 Answer 1


The answer you linked defines a vector $\mathbf v = (x_1,y_1)-(x_0,y_0)$. In your case, you would have $\mathbf v = (9,13) - (3,4) = (6,9)$, since vector addition and subtraction is just elementwise. This vector is the difference between your starting place and your ending place, and represents the movement you have to make. It points in the direction that you need to move, and its length, $||\mathbf v|| = \sqrt{6^2 + 9^2} \approx 10.8$ is the total distance you have to move.

Then we normalize it, by defining $\mathbf u = \frac{\mathbf v}{||\mathbf v||} \approx (0.55,0.83).$ The division is element-wise like our earlier subtraction: we divide 6 by 10.8 and 9 by 10.8. $\mathbf u$ still points in the same direction as $\mathbf v$, but it has length 1. So $\mathbf u$ represents the movement you will make when you move a distance of 1 along the path towards your endpoint.

You want to move 3 units, so you need to multiply $\mathbf u$ by 3. $3\mathbf u$ is the difference between your starting position and your ending position after moving 3 units, so your position after moving three units from $(3,4)$ will be $(3,4) + 3\mathbf u$, or about $(4.66,6.50).$

  • $\begingroup$ This is fantastic! Thank you so much for spelling that out for me! $\endgroup$
    – Vaccano
    Dec 5, 2012 at 21:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .