I am working on a personal project in which I want to compare two unit quaternions. I want to calculate the difference in angle between the two.
This comparing works, but now I came across the situation that I want to ignore the yaw difference between the two. I really can't think of an way to do this.
Can anyone help me with this?
I used the concept in the answer given here. This is that answer:
The quaternion representation of rotation is a variation on axis and angle. So if you rotate by r radians around axis x, y, z, then your quaternion q is:
If you want to create a quaternion that only rotates around the y axis, you zero out the x and z axes and then re-normalize the quaternion:
If you want the resulting angle:
This assumes that the quaternion representation is stored: w,x,y,z. If both q[0] and q[2] are zero, or close to it, the resulting quaternion should just be {1,0,0,0}.