Finding a quaternion of rotation between two quaternions

Viewed 153

I am trying to understand quaternion rotations and have written these two code snippets to rotate a unit vector along the X-axis to the Y-axis.

// Approach 1
Eigen::Vector3f a(1,0,0), b(0,1,0);
Eigen::Quaternionf qr;
qr.setFromTwoVectors(a,b);

// Approach 2
Eigen::Quaternionf q1(0,1,0,0), q2(0,0,1,0), qr_alt;

qr_alt = q1.inverse() * q2;    // q2 = q1 * delta_q (delta_q = rotation quaternion)

However, these two quaternions are not the same. When converted to Euler angles, qr_alt results in pi radians in yaw while qr correctly results in pi/2 radians in yaw.

What is the correct way to calculate the rotation angle between two quaternions?

0 Answers
Related