I'm working on simple 3D graphics in OpenGL (java LWGJL), and I'm trying to figure out how to convert the yaw, pitch, and roll to the x, y, and z components of my Vector motion. I know how to do this using only pitch and yaw (as explained here ), but I did not find anything, explains how to integrate the roll into this formula.
I know that yawing and pitching is all that is needed to define a vector in three-dimensional space, but I also need a roll in this case. I have keys attached to various movements relative to the camera in the basic WASD configuration ( A is local to the left, W is local, and SPACE is local), so the roll affects the movement of the camera (for example, pressing D with a roll of pi / 2 (by default ) moves the camera to the right (in world coordinates), but pressing D with a roll of pi moves the camera up in world coordinates)).
Here is the code that I still have:
This works for several revolutions, but for many it leads to incorrect results.
So the question is:
How can I change my code so that it successfully calculates the x, y, and z components of my motion vector based on my desired direction (which key is pressed), given my yaw, step, and roll
I am fine using raw trig (as I try to do), a solution involving matrices or almost anything.
EDIT:
Please do not respond simply by referring to the Wikipedia article on Euler Angle. I read it and I donβt have a strong enough background in mathematics to understand how to apply it to my situation.
EDIT # 2:
I use only Euler angles to maintain my orientation between camera reorientations. For real manipulations with the camera, I use rotational matrices. If necessary, I can remove the angles of the Eulers and just use the matrix. All that matters is that I can convert from my orientation to a vector.
EDIT No. 3:
A solution was found by multiplying my vector forward by my rotation matrix, as described in the comment:
Still a problem with that .