## [Vector product and dot product] How to express using Eigen

nkamennoff
Registered Member
Posts
2
Karma
0

### [Vector product and dot product] How to express using Eigen

Thu Dec 06, 2012 5:37 pm
Hello,

As I'm quite new in Eigen and considering my vector mathematics belong to past I just wonder something.

I have to implement the following test, described in a paper :
(v0 x v1) . v > 0 && (v1 x v2) . v > 0 && (v2 x v0) . v > 0

I tried the following code :
Code: Select all
`Eigen::Vector3d v[3];Eigen::Vector3d w;// Unrelated initialization stuff...if (w.dot(v[0] * v[1]) > 0 && w.dot(v[1] * v[2]) > 0 && w.dot(v[2] * v[0]) > 0){  // The things I wanna do...}`

It ended (at compile time) by the follow message :
In file included from /usr/include/eigen3/Eigen/Core:321:0,
from /usr/include/eigen3/Eigen/Dense:1,
from /home/niko/Projects/LandySzalayEstimator/sources/../includes/trixel.hpp:12,
from /home/niko/Projects/LandySzalayEstimator/sources/trixel.cpp:1:
/usr/include/eigen3/Eigen/src/Core/Product.h: In member function ‘const typename Eigen::ProductReturnType<Derived, OtherDerived>::Type Eigen::MatrixBase<Derived>::operator*(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = Eigen::Matrix<double, 3, 1>, Derived = Eigen::Matrix<double, 3, 1>, typename Eigen::ProductReturnType<Derived, OtherDerived>::Type = Eigen::GeneralProduct<Eigen::Matrix<double, 3, 1>, Eigen::Matrix<double, 3, 1>, 2>]’:
/home/niko/Projects/LandySzalayEstimator/sources/trixel.cpp:176:36: instantiated from here
/usr/include/eigen3/Eigen/src/Core/Product.h:579:3: error: static assertion failed: "INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS"

But that does not ring me a bell...
Has anyone got an idea ?

Thanks.
jitseniesen
Registered Member
Posts
204
Karma
2

### Re: [Vector product and dot product] How to express using Ei

Thu Dec 06, 2012 6:24 pm
The dot product v . w in Eigen is v.dot(w) and the cross product v x w in Eigen is v.cross(w), so the triple product (v0 x v1) . w is written in Eigen as v0.cross(v1).dot(w) .

Also see http://eigen.tuxfamily.org/dox/QuickRefPage.html , section "Arithmetic Operators".
nkamennoff
Registered Member
Posts
2
Karma
0

### Re: [Vector product and dot product] How to express using Ei

Fri Dec 07, 2012 3:33 pm
Seems to work.
Thanks a lot, the link you just gave me is clearly usefull !

## Who is online

Registered users: albertoa, askinner, Baidu [Spider], Bing [Bot], cedric, davidemme, drosca, Exabot [Bot], Google [Bot], google01103, Hans, jlarrieux, jmacleod, koriun, M4he, malsharif, MSNbot Media, osfe, paulus3005, pranavar, smankowski, Sogou [Bot], vpinon, Yahoo [Bot]