I can't comment other posts yet. ShawnFeatherly in this post wrote:
Here's a way to get the local rotation of just the y-axis. This function can be modified to get the x or z-axis.
/// <summary> isolate the y-Component of a rotation </summary>
private Quaternion yRotation(Quaternion q)
{
float theta = Mathf.Atan2(q.y, q.w);
// quaternion representing rotation about the y axis
return new Quaternion(0, Mathf.Sin(theta), 0, Mathf.Cos(theta));
}
It works for me! But how can I change this to get xRotation and zRotation? My quaternion representation is (x, y, z, w). Thanks!