# 3D Vectors

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 08-13-2003
PotitKing
I suggest you learn some vector math before doing this, It's always helpful ;)
• 08-13-2003
Silvercord
just to sum up what everyone said, first find the *speed* that you want to move this frame, then you find the direction you want to move in. The direction you want to move in has a length of one, therefore when you add the direction multiplied by speed you move speed units in the direction of your unit vector

float speed = 5;

Vector3 Direction = Vector3(1, 0, 0)
Direction's length is obviously one, when you multiply Direction by 5 you get
Vector3(5, 0, 0) therefore you move 5 units along the x axis

Here's one that's not so obvious
Vector3 Direction = Vector3(.707, 0, .707)

Direction has a length of 1
sqrt(.707^2+.707^2) = 1

Position = Position + (Direction * speed)

but the same idea works
• 08-16-2003
Zach L.
Quote:

Originally posted by Azmeos
Ok, so

magnitude = sqrt(x^2+y^2+z^2);

where x, y and z are really x1-x2, y1-y2, and z1-z2 ?

Not quite... You got it backwards (granted, for finding the magnitude this doesn't matter, but for the direction vector it does).

It should be 'destination - current_location' (x2 - x1, etc...).

*edit*

I'd take PotitKing's advice. If you can't find sufficient resources online, then Dover publishes some good and inexpensive books on the subject.
Show 80 post(s) from this thread on one page
Page 2 of 2 First 12