Home > Software design >  Eigen::Quaternion::FromTwoVectors(a, b) * a != b
Eigen::Quaternion::FromTwoVectors(a, b) * a != b

Time:05-06

I am trying to get the quaternion representing the rotation from unit vector a to unit vector b.

As a sanity check this quaternion should garantee this equality q * a = b. The Eigen function Quaterniond::FromTwoVector https://eigen.tuxfamily.org/dox/classEigen_1_1Quaternion.html doesn't seem to respect my intuition. You can check here https://godbolt.org/z/rrb3Ev9cf (for a = {0, 0, -1} and b = {-0.0082091040565241327, 0.15209511189816791, -0.89586970189502269}).

Am i missing something ? Is there some condition that a and b must verify for this to be true ?

CodePudding user response:

A check with R:

> crossprod(c(-0.0082091040565241327, 0.15209511189816791, -0.89586970189502269))
          [,1]
[1,] 0.8257828

shows that your vector b is not a unit vector.

  • Related