Eigen access quaternion coefficients data elements
Alec Jacobson
October 24, 2012
For some reason, using eigen's Quaternion class I could not figure out how to access the underlying data: the x,y,z,w coefficients of the xi + yi + zi + w quaternion representation. I tried using
Eigen::Quaterniond q;
function_needing_double_pointer(q.data());
but the data() method doesn't exist so you get:
error: 'Eigen::Quaterniond' has no member named 'data'
I also tried just referencing to the first coefficient (which confusingly is x despite the constructor using w,x,y,):
function_needing_double_pointer(q.data());
seems works if you first assign to a pointer, but otherwise you get:
error: lvalue required as unary '&' operand
This seems like the "correct" solution:
function_needing_double_pointer(q.coeffs().data());