Re: [eigen] initialize vector3d from array

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


You can even map the entire array as a matrix:

Map<Matrix<double,3,Dynamic> > vecs(a,3,n);

and get individual vectors as vecs.col(i), or process them at once, e.g.:

vecs.colwise().normalize();

vecs = AngleAxisd(0.3, Vector3d(1,1,1).normalized()) * vecs;


gael

On Fri, Nov 6, 2015 at 10:43 AM, Sergiu Dotenco <sergiu.dotenco@xxxxxxxxx> wrote:

On 11/6/2015 2:01 AM, Nico Schlömer wrote:
> Hi everyone,
>
> I have a large array with the data organized like
> ```
> x0, y0, z0, x1, y1, z1, ...
> ```
> I would like to create some `const Vector3d` from these. How can I do
> that most efficiently?
>
> Cheers,
> Nico

You can use a map:

double a[] = { ... };

Eigen::Map<const Eigen::Vector3d> > vec1(a);
Eigen::Map<const Eigen::Vector3d> > vec2(a + 3);

and so on.





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/