c++ - Row wise cross product Eigen -
i trying cross product between every row of 1 eigen::matrixxd dir corresponding row of eigen::matrixxd v0v2 , save result in eigen::matrixxd pvec.
initialization of pvec : eigen::matrixxd pvec(v0v2.rows(), 3);
i have tried dirty method:
for(size_t = 0; < v0v2.rows(); i++){ pvec.row(i) = dir.row(i).cross(v0v2.row(i)); }
i error : this_method_is_only_for_vectors_of_a_specific_size
i thought because of column-major/row-major issue added .transpose() doesn't either. dirtier personal cross product element wise this:
vec3 crossproduct(const vec3<t> &v) const { return vec3<t>(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); } eigen method. great!
the arguments of .cross must known @ compile-time of size 3. try declaring matrices eigen::matrix<double, eigen::dynamic, 3> dir(n, 3);, etc.
Comments
Post a Comment