#### Archived

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

# 3D Vector Movement

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

## 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 on other sites
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 on other sites
Thanks. So what do I do with each of those numbers? Add them to the original coordinates? Or what?

##### 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]