Re: [eigen] Quaternion initialization from Block/segment (Eigen 3 beta 1)

[ Thread Index | Date Index | More Archives ]

On Thu, Jul 22, 2010 at 6:33 PM, Jens Andersen <jens.andersen@xxxxxxxxx> wrote:
> Eigen::VectorXd myvector;
> Eigen::Quaternion q(myvector.segment(3,4));
> I'm not sure whether this method avoids the copy?

To make it compile you have to set the vector length at compile time:

Eigen::Quaternion q(myvector.segment<4>(3));

And indeed this copy the data to a new array. In Eigen3 you can map
external memory as a Quaternion without any copy using Map:

Map<Quaterniond> q(myvector.segment(3,4).data());


Map<Quaterniond> q(&myvector(3));


Mail converted by MHonArc 2.6.19+