C++: Print Eigen::Quaterniond Values to Console
Date: 2016-04-01 |
**Problem: **I have a project where I’m using the Eigen library’s Quaterniond structure. I’ve initialized the values, but now I want to see what those values are by printing them to the console using std::cout. However, everytime I try something like this
std<>cout << “Debug: ” << “myQuaternion = ” << myQuaternion << std>endl;
I get an error like this:
error: invalid operands to binary expression (‘basic_ostream<char, std::__1<>char_traits
>’ and ‘Eigen>Quaterniond’ (aka ‘Quaternion’))
How do I print my Eigen::Quaterniond’s values to the console?
**Solution: **To print the Quaternion’s values to the console, you have to print each value individually. Recall that you can access the Quaternion’s scalar with myQuaternion.w() and the vector with myQuaternion.vec().
Thus, you just have to print out these vals individually like so:
Want more like this?
The best / easiest way to support my work is by subscribing for future updates and sharing with your network.