# XY rotation directions

I have a simple WASD controller to rotate the player, but if I press W and the player has been rotated by 20 degrees, it will only rotate around the x axis.

Yes, it's logical, but how I should I calculate rotation around the x and y axis?

• Please note the changes I have made. rotation is different to translation, and it was clear that you were asking about rotation, but appeared to be using translation-based terms. That said, I am still somewhat confused by your question; The problem you describe does not make sense (if you rotate around any axis by 20 degrees, you can change the local axis, and thus alter the way further rotation applies; it should not prevent such rotation, outright), and to be perfectly honest, the parts of this question I do understand have already been covered multiple times on this very site. – Gnemlock Feb 19 '17 at 3:51
• What have you tried, so far? And when you say "rotate 20 degrees", what axis are you rotating around? Is there any visual representation you can give of what you have, at the moment? – Gnemlock Feb 19 '17 at 3:51
• This question is poorly phrased, contains insufficient information, and is three months old. Why was it bumped? – 3Dave Jun 2 '17 at 22:40

You just have to use the trigonometric ratios. Lets say that you have rotated the character 20 degrees and you have a speed of 2 pixels per update.

PosX += cos(20)*2
PosY += sin(20)*2


In this example the x would increase with 1.88 pixels and the y would increase with 0.68 pixels per update.

• The question is about rotation, not translation. – 3Dave Jun 2 '17 at 22:40
• Try and read the post before the edit. He wanted to know how much x AND y would increase if it was rotated. – Klemmensen Jun 6 '17 at 8:43