Skip to main content
gamedev.net
🔒 Locked

Vector from Angle

Started by kelaklub Aug 29, 2003 at 11:26 AM 8 replies 550+ views
Original Post
kelaklub
kelaklub
If all I have is a 2d point and an angle, is there a way to get a vector of arbitrary length(unit vector prefered) from that point along the angle. Thank you.
Strife
Strife
Of course. You don''t even actually need the angle, but simple the point (since that point essentially contains the angle within it). In fact, that point *is* the vector itself, starting from the origin. If you then want a unit vector, just normalize that.

The Artist Formerly Known as CmndrM

http://chaos.webhop.org
kelaklub
kelaklub
What if that point is at the origin?
kelaklub
kelaklub
That's it. Thank you so much. Actually I figured it out but I just wasn't sure why whatever I was doing was working, thanks for laying out the mathematical foundation.

[edited by - kelaklub on August 29, 2003 1:13:53 PM]
GCoder
GCoder
Think about the parametric equation of a circle...(looking DOWN the Y acis)

x = a + (r * sin(theta) )
z = b + (r * cos(theta) )

where x and z are your vector points (in 2D) and a and b are the position of the point, or 0 and 0 if at the origin and r is the radius of the circle.

you have to picture 0 degrees as "North" or UP, or maybe (0, 1) as a 2D vector in the XZ plane. Then, imagine rotating a vector by hand, or drawing it on paper, about the origin by whatever angle. The new position of the end of the vector is the x and z value computed above.

This example rotates around the Y axis....it can be used in exactly the same way with a little alteration for rotation about all 3 axis....everything is just done in 2D steps.

Hope that helps...and hope I havn''t made a stoopid mistake! ;o)

see how you get on,

GCoder
GCoder
Strife
Strife
The AP is correct. I mispoke, as there really is no "starting point" per se of a vector. However, there *is* one using the geometric interpretation of a vector, and that is what I meant by that.

The Artist Formerly Known as CmndrM

http://chaos.webhop.org

Topic Locked

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

Sign in to reply to this topic.