Skip to main content
gamedev.net
🔒 Locked

Rotating Vector

Started by NoNseNse 0 replies 400+ views
Original Post
NoNseNse
NoNseNse
I''m using a 2d-vector to do my colision detection in my game, so it''s ellipses which I collide. Works great, but only if the objects are on 0 or 180 degrees rotation. I lack the code to rotate the vector around the z-axis. I know the respective 4x4-matrix, but don''t know what to multiply with what. So any help is appreciated, THX,, NoNseNse
acw83
acw83
You don''t really need matrices for a 2d rotation.

new_x = old_x * cos(angle*180/3.14159) - old_y * sin(angle*180/3.14159);
new_y = old_x * sin(angle*180/3,14159) + old_y * cos(angle*180/3.14159);

Hope that helps.

Topic Locked

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

Sign in to reply to this topic.