I have two pieces of information: a 2D-vector representing velocity relative to a grid and an angle (180 to negative 180 degrees) representing the player's view-angle also relative to that grid, and I am from that trying to figure out what keys (W, A, S, D) the player is pressing with this information.
The thing that is giving me troubles are the fact that the player moves in respect to the view-angle. So if the player is looking 35 degrees relative to our grid and pressing forward (W), the player will move forward 35 degrees which gives the velocity a mixture of forward and right (D). Something to note is that the maximum speed that a player gets from pressing a key is 250 units/s in that direction. But the vector gets taken into some calculation with the view angle which yields the final movement-speed, and this is why I'm asking this question.
I basically want to cancel out the angle's impact on the velocity vector.
For this, I tried using a Rotation-matrix solution using the following formula:
x' = x*cos(angle) - y*sin(angle)
y' = x*sin(angle) + y*cos(angle)
but this didn't give me good results, it seems like they are kind of the same as the original velocity vector.
Does anybody know what I'm doing wrong here? Shouldn't I just be able to calculate these values using a rotation matrix?