Recently, in the study of VR, I saw the code of the sensor processing by Google Cardboard, and did some research on gyroscope, rotation matrix and Rodrigo formula.
The physical significance of gyroscope data: the data obtained in the gyroscope is stored in (x, Y, z), which represents the angular velocity of the gyroscope in the (x, Y, z) direction. The status on the headset device is shown in the following figure.
This time (x, y, z) direction may be different from the mobile phone level, the specific changes can be tested under their own.
We look at the processing of gyroscope data by Google Cardboard.
Specific code in VR development-the study of the Rodrigo formula
Here are a few lines of code:
This.mu.set (Gyro);
This.mu.scale (-DT);
So3util.so3frommu (This.mu, this.so3lastmotion);
This is the gyroscope data processing, gyro is the gyroscope vector, by multiplying time to get the current rotation in the x, y, z direction angle, then the Rodrigo rotation matrix calculation, to get the rotation matrix. The parameter passed in by the function is MU and results are returned.
The Rodrigo formula calculates the rotation matrix by the rotation axis and the rotation angle, at which point the vector mu of the incoming parameter is the angle of rotation, and the vector mu is the axis of revolution. There may be some misunderstanding, why the vector mu represents both the axis of rotation and the angle of rotation. Assuming that both Y and Z are zero, the rotation angle in the Y and Z directions is zero, and only the x-axis is rotated (x,0,0), then the resulting rotation matrix must be rotated by the x-axis and the x=θ angle. At the same time, assuming that only Y and Z are not zero, the same result is obtained, and the axes are rotated by Y and Z respectively, so we get the conclusion that in three dimensional space (x, y, z) vector is the axis of rotation. At this point, the modulus of the vector represents the rotation angle can also be understood, representing the x, Y and z direction of the angle and.