Cross-product matrix in Eigen

wl2776 picture wl2776 · Oct 1, 2014 · Viewed 10.7k times · Source

Is there a ready function or method in Eigen for the Hat operator? That is the operator, returning a matrix, which mimics a cross product with that vector. I know, that it can be easily written, but would like to avoid it:

Eigen::Vector3d t = // some vector ;
Eigen::Matrix3d t_hat;
t_hat << 0, -t(2), t(1),
    t(2), 0, -t(0),
    -t(1), t(0), 0;

Answer

Phil picture Phil · Apr 20, 2015

As you noted both cross and the cross3 methods actually perform the multiplication. But you want to make the skew-symmetric matrix representation of t.

What you have seems like the best you can do for Vector3d and Matrix3d. Generalizing for various types of t will require more time than I have right now, but it is an interesting question, so I may investigate later.