Reply to topic

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

nkamennoff
Registered Member
Posts
2
Karma
0
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
186
Karma
2
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
Seems to work.
Thanks a lot, the link you just gave me is clearly usefull !

 
Reply to topic

Bookmarks



Who is online

Registered users: Alexa [Bot], anli, Baidu [Spider], Bing [Bot], binro, Exabot [Bot], Ganitzsh, garthecho, Google [Bot], google01103, ken300, koriun, lazyit, Majestic-12 [Bot], Nerdfest, netpalantir, SeaJey, SecretCode, sfepa, vascobasque, W3C [Validator], Yahoo [Bot]