Re: [eigen] Quaternion toRotationMatrix

[ Thread Index | Date Index | More Archives ]

This is basically what was suggested here:

The thing is (as you noted) that so far Quaternions are always assumed to be unit-quaternions, and silently introducing a division might give unnecessary overhead for some users. Our idea (which we never finished to decide on) was to introduce different Quaternion classes, which assume unity, or don't. Also see this and the dependent bugs:


On 30.09.2015 17:38, Gabriel wrote:

I have the following suggestions for the function *toRotationMatrix()*
for the *QuaternionBase* class:

The function is shown here:

The documentation says that this function is undefined if a non unit
quaternion is used! This is absolutely correct!

The function so far implemented is equation 1.112 in ( tilde is the skew-symetric matrix of a
vector  -> cross product)

If we want to use the Eigen function *toRotationMatrix*()   we need to
normalize the quaternion beforehand which is expensive!

A better way is to use equation 1.110 directly in, which directly normalizes the quaternion but
only needs the square norm of the quaternion "s"
which is much cheaper. Equation 1.110 directly gives a proper rotation
matrix! (orthogonal, and det(R)=1)

I would provide the following adaption:

*template<bool isQuaternionNormalized = false>**


*toRotationMatrix**<true>*       -> same function as already implemented
(user should use this if quaternion is already normalized)
**toRotationMatrix**<false>*      -> no normalized quaternion is given
as argument, use an implementation which uses equation 1.110 in

Maybe the default behavior should be "true" so there is no change to the
interface for the user who used these functions....

*BR Gabriel Nützi**

 Dipl. Inf., Dipl. Math. Christoph Hertzberg

 Universität Bremen
 FB 3 - Mathematik und Informatik
 AG Robotik
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Zentrale: +49 421 178 45-6611

 Besuchsadresse der Nebengeschäftstelle:
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Tel.:    +49 421 178 45-4021
 Empfang: +49 421 178 45-6600
 Fax:     +49 421 178 45-4150
 E-Mail:  chtz@xxxxxxxxxxxxxxxxxxxxxxxx

 Weitere Informationen:

Mail converted by MHonArc 2.6.19+