Re: [eigen] Quaternion toRotationMatrix |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Quaternion toRotationMatrix*From*: Dick Lyon <dicklyon@xxxxxxxxxx>*Date*: Wed, 30 Sep 2015 08:47:15 -0700*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=jWyQUOC8oQZkbpsy59W69bkBEpidPJXia1lXkdpf9pk=; b=TegGk15Z7tDzbtLYT946vPZpE8kGEV8QFEkObXElkaHHBgLdv7+gm7mILkJm0BTrxk 7U/Z7wlUmXNsFTf7+Dt39WuVodF8+imIiBM5k26wezH7PTpC9EnwvKc1Ti37Lwtcv2eH uH5V89yPuBxKHc/8vSQ8QB1IN9ESwFzvjtCYGXBP9Oj88N5x2T32oY4vj83lP1ThYN+4 Z0LPoyGYiW5DhOXUs6+vdrwyEGvEjFXmYsE0C5fzkMVkBLCsxmiap3a2l/xZRz+PYbpp f1ODyjJuCSeR/H6Z2n8LHaxpF7pnHluauaR9Mm14elA2kA0/j+I0GXU14ebvoAx/NNtM KM1g==

What not always do the latter (the <false>), an maybe optimize away the divide if s is equal to 1 (within some precision)?

On Wed, Sep 30, 2015 at 8:38 AM, Gabriel <gnuetzi@xxxxxxxxx> wrote:

Hello,

I have the following suggestions for the functiontoRotationMatrix()for theQuaternionBaseclass:

The function is shown here:

http://pastebin.com/QPRANVU6

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 http://snag.gy/J6rDH.jpg ( tilde is the skew-symetric matrix of a vector -> cross product)

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

A better way is to use equation 1.110 directly in http://snag.gy/J6rDH.jpg, 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>

QuaternionBase<...>::toRotationMatrix()

where

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 http://snag.gy/J6rDH.jpg

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

**Follow-Ups**:**Re: [eigen] Quaternion toRotationMatrix***From:*Gabriel

**References**:**[eigen] 3.3-alpha1 released!***From:*Gael Guennebaud

**Re: [eigen] 3.3-alpha1 released!***From:*Sergiu Dotenco

**Re: [eigen] 3.3-alpha1 released!***From:*Gael Guennebaud

**[eigen] Quaternion toRotationMatrix***From:*Gabriel

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] Quaternion toRotationMatrix** - Next by Date:
**Re: [eigen] Quaternion toRotationMatrix** - Previous by thread:
**[eigen] Quaternion toRotationMatrix** - Next by thread:
**Re: [eigen] Quaternion toRotationMatrix**

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