Registered Member
|
Does Eigen have a function to get the shortest arc quaternion between 2 vectors?
i.e.
I can do it with something like:
But can have problems when v0 is close/parallel to v1. I pulled this from my old game programming gems book and ported it to Eigen syntax:
However this still will fail when v0 = -v1. So we can "improve" it a little more with:
This is quickly getting slow ugly and hairy. Does Eigen have this utility? This seems like a fairly common task with a good deal of edge cases. |
Moderator
|
q.setFromTwoVectors(v0,v1);
The doc says: /** Sets \c *this to be a quaternion representing a rotation between * the two arbitrary vectors \a a and \a b. In other words, the built * rotation represent a rotation sending the line of direction \a a * to the line of direction \a b, both lines passing through the origin. * * \returns a reference to \c *this. * * Note that the two input vectors do \b not have to be normalized, and * do not need to have the same norm. */ |
Registered Member
|
Ah wonderful I searched pretty hard but missed this thank you!
EDIT: Looking for it again I still can't find it in the docs anywhere. http://eigen.tuxfamily.org/dox/classEig ... mbers.html Also seems kind of a shame to have to do 2phase initialization i.e. Quaternion q; q.setFromTwoVectors( v0, v1 ); Still THANKS |
Moderator
|
yes, doxygen has some difficulties with Eigen's c++ code
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]