Sunday, November 13, 2011

How do I split a vector into 2 perpendicular vectors?

I'm creating a game, and the player has a velocity (x, y), and a rotation.





I want to split the velocity into 2 vectors where one of them points in the direction the player is going, and the other points at a right angle.





Adding those 2 vectors together would result in the original velocity vector.|||use the Gram-Schmidt process to create orthogonal (perpendicular) vectors. check the link below for full details|||One would be the vector times the sine of that angle, the other would be the vector times the cosine of that angle. One is the y-axis, the other is the x-axis. Follows from basic trig.

No comments:

Post a Comment