Skip to main content
GameDev.net gamedev.net
🔒 Locked

Traversing a Vector

Started by Darobat Jan 15, 2005 at 9:20 AM 3 replies 700+ views
Original Post
Darobat
Darobat
Greetings If I have a vector, AB, how can I traverse that vector at a constant speed to get from A to B.
--------------------C++ Home - Check it out!Lol... - Amazing video
Dmytry
Dmytry
P=A+(B-A)*t
will move from A to B as t will change from 0 to 1.
if you need certain speed, use
D=B-A;
D.Normalize;
...
P = A+D*time*speed;
phaelax
phaelax
Well from point A to B you would subtract the two to get a vector, then multiply that with a number "t" in [0,1].

new point = (B-A)*t + A

edit: beaten to it.
Darobat
Darobat
Ah, thankyou! That worked.

Another question though. Once Again I have 2 vectors, how could I rotate about B, keeping the lenght of AB constant. It is for a camera class I am making.

[Edited by - Darobat on January 15, 2005 10:37:05 AM]
--------------------C++ Home - Check it out!Lol... - Amazing video
Darobat
Darobat
Not tryign to bump my topic, just wondering if any one knows.

Oops. By posting I am bumping!
--------------------C++ Home - Check it out!Lol... - Amazing video

Topic Locked

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

Sign in to reply to this topic.