Re: [eigen] Mapping array of scalars into quaternions

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


2009/10/22 Mathieu Gautier <mathieu.gautier@xxxxxx>:
> Hi,
>
>> typedef Quaternion<MyScalar> MyQuat;
>>
>> and not:
>>
>> typedef Quaternion<Matrix<MyScalar,4,1> > MyQuat;
>>
>> right ?
>
> Yes, I want to keep the former Quaternion notation.
>
>>
>> then the first template argument of Quaternion must be the scalar type.
>> But if we prefer we can also introduce a QuaternionBase and a
>> QuaternionWrapper classes like we did for DiagonalMatrix. Of course this is
>> more work, but perhaps that's a good idea to harmonize that over Eigen.
>
> Besides quaternions, i want to have two distinct members of Lie algebras
> which represent angular velocities of a rigid body or torques applied on a
> rigid body which could be represented by vectors of 3 elements. I need to
> have a Lie bracket [A,B] = AB - BA which had a specific implementation for
> thoses vectors. Moreover, I need a map mecanism to interface Eigen with an
> another library.
>
> So, I have severals options :
>
> 1) Add this function in MatrixBase (through the plugin mecanism) whith some
> asserts to check that the function is called only on vectors.
>
> 2) Do something similar to the actual Quaternion class with (a proper
> version of) my patch.
>
> 3) Inherit a new class (FooBase) from MatrixBase and introduce two other
> classes Foo and FooWrapper.
>
> Since, these new objects are vectors (like quaternions in fact), the 1st and
> 2nd options would benefit from the map mecanism of matrices.
>
> The 3rd option looks like what we actually have in our own libraries that
> could reduce my work to adapt our algorithms to Eigen.
>
> So, I wonder which option to choose in regards with your opinion on Wrapper
> and map mecanisms.

The first thing is to decide if you want your objects to _be_
3-vectors or to _contain_ a 3-vector.

If you want them to be a 3-vector and you think they should be usable
like any other 3-vector, then you could just let your class inherit
MatrixBase. That leads to your solution 3). Otherwise, don't inherit
MatrixBase. That would look like solution 2).

The situation of diagonal matrices that Gael is referring to is in
Core/DiagonalMatrix.h. Here, incidentally, we had decided to NOT
inherit MatrixBase because e.g. implementing diagonalmatrix(i,j) with
an "if(i==j){...}" would be slow and useless in practice. Anyway,
regardless of that, we just introduced a DiagonalBase class and
deferred the specifics of storage to subclasses DiagonalMatrix and
DiagonalWrapper.

For quaternion, thus, the "proper" version of your patch would look
very specific to that. QuaternionBase would inherit RotationBase.

Cheers,
Benoit



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