Artificial intelligent assistant

Comparing Unit Quaternions ignore YAW 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:


q[0] = cos(r/2)
q[1] = sin(r/2)*x
q[2] = sin(r/2)*y
q[3] = sin(r/2)*z;


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:


q[1] = 0;
q[3] = 0;
double mag = sqrt(q[0]*q[0] + q[2]*q[2]);
q[0] /= mag;
q[2] /= mag;


If you want the resulting angle:


double ang = 2*acos(q[0]);


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}.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 08b253e2344fe98cd20ae7836ff6c390