Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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).$

share|improve this answer
    
This is fantastic! Thank you so much for spelling that out for me! –  Vaccano Dec 5 '12 at 21:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.