Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Find point on a line, given distance?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 dnatapov   Members   -  Reputation: 122

Like
0Likes
Like

Posted 01 April 2008 - 08:06 AM

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!

Ad:

#2 Bob Janova   Members   -  Reputation: 761

Like
0Likes
Like

Posted 01 April 2008 - 08:57 AM

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

e: bad bold tag polarity

#3 Álvaro   Members   -  Reputation: 5795

Like
0Likes
Like

Posted 01 April 2008 - 08:58 AM

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)


#4 Bob Janova   Members   -  Reputation: 761

Like
0Likes
Like

Posted 01 April 2008 - 09:09 AM

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

#5 dnatapov   Members   -  Reputation: 122

Like
0Likes
Like

Posted 01 April 2008 - 10:03 AM

Quote:
Original post by Bob Janova
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).

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


#6 shurcool   Members   -  Reputation: 435

Like
0Likes
Like

Posted 01 April 2008 - 10:14 AM

Quote:
Original post by dnatapov
Quote:
Original post by Bob Janova
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).

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS