Convert Yaw, Pitch, Roll from gyro to forward & up vector for OpenAl Listener Orientation

153 Views Asked by At

I am trying to implement a orientation setter for Openal, but I after searching through dozens of websites, I have yet to found the correct formula to converting the yaw, pitch, and roll values from my MPU6050 gyro sensor to the x,y,z forward vector and the x,y,z up vector that the Listener.set_orientation requires.

I have found a few formulas but all of them have different variations and differences.

This is one of them I have found, but the sound keeps fluctuating from one side of my headphone to the other for some reason:

forward.x =  cos(pitch) * sin(yaw);
forward.y = -sin(pitch);
forward.z =  cos(pitch) * cos(yaw);
up.x = sin(pitch) * sin(yaw);
up.y = cos(pitch);
up.z = sin(pitch) * cos(yaw);

Anyone know the solution? Thanks in advance.

0

There are 0 best solutions below