Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Azmeos

3D Vector Movement

This topic is 5398 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 know this sounds simple, but I can''t figure out how to move a spaceship along a vector at a set speed. I know how to calculate the vector magnitude, but if the speed is say, 50, how do I calculate the per-second components of x, y, and z at that speed?

Share this post


Link to post
Share on other sites
Advertisement
Say your vector is {x, y, z}, and the speed you want is s.

Work out the vector magnitude, m.

Scale x, y and z by (s/m) to give a new vector, with components

{x *s/m, y * s/m, z * s/m}.

This is the vector, with the ''per-second components'' you want. It will also work for the per frame speed: just use the correct s (e.g. a speed of 50 units per second and 30 fps gives s = 50/30 units per frame).

Share this post


Link to post
Share on other sites
Thanks. So what do I do with each of those numbers? Add them to the original coordinates? Or what?

Share this post


Link to post
Share on other sites
Position(t) = Position(t=0) + velocity * t (assuming your velocity is constant).

EDIT: Oh, and if you have a speed and a direction to move, then scale your direction (given you have it as a vector) to the speed (50 in your example) and you have the velocity.

[edited by - Atheist on August 13, 2003 1:27:43 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!