# Find point on a line, given distance?

This topic is 3706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I've been frustratingly stuck with the math for this, and was hoping someone could help out. I have two points: A,B in 3D space (and therefore a line between them). I'm looking for a third point, C, along this line, a specific distance away from point B. But in the direction of point C. How do I find this point? I've tried using similar triangles, and parametric line equations but I'm getting strange results, and I'm not sure if it's borked code or borked math... Trying to verify the math, or find a better way of doing this. Thanks in advance!

##### Share on other sites
Use vectors. C = B - k(A - B). k = (the distance you want) / (distance from A to B), or k = proportion of distance to place C (0: place at B; 1: place at A).

##### Share on other sites
Part of the description of what you want made no sense ("in the direction of point C"?).

There are two points that are in that line whose distance to C is d:
C = B + (A-B)*d/distance(A,B)C = B - (A-B)*d/distance(A,B)

##### Share on other sites
I'm pretty sure that by 'on this line' he means between A and B.

##### Share on other sites
Quote:
 Original post by Bob JanovaUse vectors. C = B - k(A - B). k = (the distance you want) / (distance from A to B), or k = proportion of distance to place C (0: place at B; 1: place at A).e: bad bold tag polarity

Ah there it is!
I was doing C = A + k(A - B);

It seems to work now. Thanks a lot for the help! :D

##### Share on other sites
Quote:
Original post by dnatapov
Quote:
 Original post by Bob JanovaUse vectors. C = B - k(A - B). k = (the distance you want) / (distance from A to B), or k = proportion of distance to place C (0: place at B; 1: place at A).e: bad bold tag polarity

Ah there it is!
I was doing C = A + k(A - B);

It seems to work now. Thanks a lot for the help! :D

That's how I would've done it, except it's C = A + k(B - A). A is the starting point, (B - A) is the vector pointing in the direction of B if you take A as the origin.

• 15
• 9
• 13
• 41
• 15