Essay - Published: 2016.04.01 |
DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)
**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
stdcout << “Debug: ” << “myQuaternion = ” << myQuaternion << stdendl;
I get an error like this:
error: invalid operands to binary expression (‘basic_ostream<char, std::__1char_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:
The best way to support my work is to like / comment / share for the algorithm and subscribe for future updates.