What’s the difference between Quaternion subtraction/addition and Quaternion inverse operation?

  animation, c++, math, quaternions

I was reading a document about Additive Animation , which add some animation to another;

The code below demonstrate the algorithm:

glm::quat rotDiff = rotQuat2 * glm::inverse(sourceRot);
glm::vec3 posDiff = posVec2 - sourceVec;
auto rotQuat = rotQuat1* rotDiff;
auto posVec = posVec1 + posDiff;

rotDiff is the rotation which should be added to origin animation;
The rotDiff is calculated with rotQuat2 * glm::inverse(sourceRot), this is One line I don’t fully understand,
The third line rotQuat = rotQuat1 * rotDiff is the another I don’t fully understand.

If I were write this algorithm, I would like to rotDiff = rotQuat2 - sourceRot
rotQuat = rotQuat1 + rotDiff, ie, use subtraction instead of multiply the inverse of sourceRot, use addition instead of multiplication, because this is intuitive.

Could you please explain the difference ?

The quaternion class is like this https://cs.stanford.edu/~acoates/quaternion.h

Source: Windows Questions C++

LEAVE A COMMENT