C++: How to Add Two Eigen::Quaterniond Structures
Problem: I’ve got two Eigen::Quaterniond values that I’m trying to add together. However, whenever I try to use the standard plus/addition (+) operator, it throws an error saying that function isn’t implemented. How can I add my two quaternion’s together?
Solution: Luckily, the solution is pretty simple, albeit tedious. Recall that an Eigen::Quaterniond’s value can’t be accessed directly. Instead, you have to use “getter” methods to access those values. For instance, you would use myQuaternion.w() to get the scalar and myQuaternion.vec() to get the vector portion of the quaternion.
So, to add two quaternions together, you would write code similar to this example:[https://gist.github.com/SIRHAMY/6d7a14a4dbeb3126ff89]