Q:

How do I use cross product on variable sized vectors

I'm using Eigen::VectorXf and I want to compute the cross product using two parts of these two vectors. For example :
Eigen::VectorXf vect_1 (6), vect_2 (6), vect_3 (6);
// Put some values into the vectors
vect_3 = vect_1.cross(vect_2); // Doesn't work because vector size != 3
// Would work with Eigen::Vector3f

I would like to compute the cross product using the last 3 coordinates and store it into the last 3 coordinates of vect_3
Something like :
vect_3(size = 3, offset = 3) = ...

How should I do that ?

A:

Eigen::Vector3f vect1,vect2;
vect1 = vect_1.segment(3,3);
vect2 = vect_2.segment(3,3);
vect_3.segment(3,3) = vect1.cross(vect2);

