This forum has been archived. All content is frozen. Please use KDE Discuss instead.

quaternion matrices

Tags: None
(comma "," separated)
chombier
Registered Member
Posts
3
Karma
0

quaternion matrices

Fri Mar 20, 2009 5:18 pm
Hi

First of all thank you so much for this great library. It's entirely made of awesome.

I wonder if it is (or will be) possible to use quaternions inside eigen2 matrices. When i try to do so, the compiler complains about NumTraits not beeing specialized for quatenion types.

So my question is: what would it take to make quaternion matrices work ? I don't really need it to be fast, but i'd really like to take advantage of the oh-so-cool Eigen2 API.

Where should I start hacking ?

thanks for your help !



max.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

RE: quaternion matrices

Fri Mar 20, 2009 5:36 pm
In order to add support for a new numeric type, you basically need 2 things: add numeric traits in src/Core/NumTraits.h, and add math functions in src/Core/MathFunctions.h.

Don't bother about vectorization, this should happen automatically if applicable. In the numeric traits, just set PacketSize to 1, even if the quaternion size may be different than 16 bytes.

Then there is another issue. Quaternions are non-commutative (ab != ba). So all Eigen code that does products of numbers has to be checked to actually do the right order. So far we didn't bother about that but suddenly for quaternions it becomes important...

You may also find that the Quaternion class doesn't have all arithmetic operators that you may want.... check that, add them if needed (we can add a EIGEN_QUATERNION_PLUGIN macro to allow you to extend that class without us supporting it....)

Last edited by bjacob on Fri Mar 20, 2009 5:38 pm, edited 1 time in total.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
chombier
Registered Member
Posts
3
Karma
0

RE: quaternion matrices

Mon Mar 23, 2009 6:00 pm
Ok that did the trick, thanks a lot. Did not find PacketSize en NumTraits though.

Non commutativity of quaternion is not a problem at this stage for me, since i'm only using Matrices for storage purposes. I'll fix these issues as they come, trying to contribute patches :)

Most of the quaternion operators i need are actually Lie-group theory related (group operations, exponential/logarithm, tangent mappings, adjoint maps) and could therefore be made available for each group of transformation in the geometry module.

This way you can e.g interpolate translations, rotations, or rigid transformation in a same unified way (some generalized SLERP), doing averages/blendings respecting the group structure, etc...

I have code for doing this in my own old matrix lib (which also happened to use expression templates and curiously recurring template pattern :-) ) that i plan to port to eigen someday. Implementing those for quaternions in eigen could be a good start to porting everything.

Do you know if this could actually be of any use to someone?

Thanks again for your answers

Last edited by chombier on Mon Mar 23, 2009 6:01 pm, edited 1 time in total.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell