Re: [eigen] Mapping array of scalars into quaternions |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Mapping array of scalars into quaternions
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 22 Oct 2009 12:07:59 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=a/c1rI87AZK9tGxEHacL/v/bgJv1zj6SSO63EFvfez0=; b=lAD0ainM3KFtJHizOKJ0VGdrcKYO1O6c8PXNxNDm6OGE9p0rqtegOOD6yJjpN0uR0A wOjzuS56/xuRI8FGGEZZez8yXbF+EzBk7kokHGTvlA33Wlk8jrIYh5H7VB2nFIHUvjpC 51QmyDf6tvCtGVStHP9Vqvw1A+5MaA6/hhFns=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=lA4Xr+K2UcRktJkvKQDRzJGIRcyTQJoKHQ1qN6ip9OmMLPy+aT4M6ESH4+wsxzOOn7 XWcUdLElj3EikXsIrIDnG0hAKS5PZ/oFQ9jBQ05GiGLVBoGuswoyH40IgxDrHwd02mt6 /L11sXqeBPs2TNGiu7QUbTgdAm3RguQKaxRrg=
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