Jump to content
  • Advertisement
Sign in to follow this  

compute 3D point on a vector

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to know how do to the following..I have a point in 3D space A(x,y,z) and another point B(x,y,z) If I travel from point A towards point B at a set velocity (meters per second) I would like to calculate at any given time the point position on the vector between A and B.. C(x,y,z)

I already know how to calculate the distance between A and B so I have that and I know the speed.. I probably could find it with google but I dont really know how to describe it for a search.. so far I have not had any luck finding it..Thanks.

Share this post

Link to post
Share on other sites
The difference vector d from point A to point B
d := B - A
denotes the direction from A to B and the distance between A and B (i.e. the length of the vector). Dividing d by its own length (i.e. normalizing it)
d' := d / |d|
results in just the direction (i.e. the steps in all dimensions related to the unit distance).

This direction should be used as the direction of the velocity, too. So, scaling this direction with the speed s gives the velocity vector
v := d' * s

A position C is reached after t time units by integrating the velocity v over time
C(t) := Int( v(t) dt , 0, t)
where, in the given case, v is independent on time here and C starts at A = C(t=0), so that
C(t) := A + v * t
as Cornstalks has already stated above.

At t=T the position C(t) will reach B
C(t=T) = A + v * T = B
so that
v * T = B - A
d / |d| * s * T = d
|d|[sup]2[/sup] / |d| * s * T = |d|[sup]2[/sup]
and finally
T = |d| / s
is the expected duration of traveling (of course).

Share this post

Link to post
Share on other sites
Thank you Cornstalks and Haegarr I was not sure how to create a velocity vector that would not wander off from the vector between A and B.This information helped a lot..thanks for helping me out.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!