← Back to team overview

yade-users team mailing list archive

Re: [Question #194486]: How to define a matrix in the c++ code ?

 

Hi Kneib

> I would like to create a matrix in the c++ code to compute the rotation of some vectors.
> I tried to declare a Matrix3r but I didn't found any way to fill it with my values. Is there a constructor for this class ?
> After that, how can I do a matrix product with a Vector3r ?

constructors could be
Matrix3r m;
m = Matrix3r::Zero();
m = Matrix3r::Identity();
Matrix3r* m(new Matrix3r); (*m)<<m00,m01,m02,m10,m11,m12,m20,m21,m22; //
from py/mathWrap/miniEigen.cpp

// or simply
Matrix3r m = Matrix3r::Zero();
m(0,0) = 1.0;
m(1,2) = 2.34;
...

By matrix product, do you mean Vector3r*Vector3r, or Matrix3r*Vector3r?
Anyway (see
http://eigen.tuxfamily.org/dox/TutorialMatrixArithmetic.html):
Vector3r v1,v2;
Matrix3r m = v1*v2.transpose();
Vector3r v3 = m*v1;


Jan



References