Skip to main content
gamedev.net
🔒 Locked

Mind blank.. directional vector

Started by Ganoosh_ Aug 25, 2006 at 8:59 PM 1 replies 700+ views
Original Post
Ganoosh_
Ganoosh_
Ok, my memory has like completely erased. I forget how to set a direction based on 2 points. Like if I wanted one object to move towards another. I know how to make it move I just forget how to compute the directional vector. All I remember is it needs to be normalized after everything. All I know is it's something between the 2 points, trig maybe? Then it's normalized and can be used. But what's the part I'm missing? Thanks in advance
swordfish
swordfish
Normalize(V1-V0) will give you a unit vector from V0 to V1.
http://blog.protonovus.com/
etothex
etothex
I'm not quite sure what you're asking. If you mean, given two points, you want the vector that points from one to the other:

given points p1 = (x1, y1, z1) and p2 = (x2, y2, z2), the displacement vector between them v = (x2 - x1, y2 - y1, z2 - z1). The length of this vector, is sqrt( (x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2 ). You can normalize the displacement vector by dividing by it's length, resulting in the direction vector.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.