# Translating yaw degrees into 2D movement

I've been hitting my head on the wall for a while with this, and I'm almost sure I'm overcomplicating it.

I have a variable for yaw in degrees (and also pitch and roll, but those should be irrelevant). I want to turn that variable into normalized 2D movement, so the distance traveled per frame should always be a constant.

I was easily able to to workout movement when I had a fixed view direction, but translating it with yaw is what's confusing me. I've been trying a combination of converting to radians, then using cos(x) and sin(x) but it only works if I'm looking in a certain direction.

Yep, was definitely overthinking it. Here's the quick version, probably some ways to optimize it:

        double x = Math.sin(Math.toRadians(yaw));
double xo = Math.sin(Math.toRadians(yaw + 90)); // 90 offset of current direction
double zo = Math.cos(Math.toRadians(yaw + 90));

if(Keyboard.isKeyDown(Keyboard.KEY_W)) {
position.z -= MOVESPEED * z;
position.x += MOVESPEED * x;
}
if(Keyboard.isKeyDown(Keyboard.KEY_D)) {
position.z -= MOVESPEED * zo;
position.x += MOVESPEED * xo;
}
if(Keyboard.isKeyDown(Keyboard.KEY_A)) {
position.z += MOVESPEED * zo;
position.x -= MOVESPEED * xo;
}
if(Keyboard.isKeyDown(Keyboard.KEY_S)) {
position.z += MOVESPEED * z;
position.x -= MOVESPEED * x;
}