Re: [eigen] Quaternion toRotationMatrix
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] Quaternion toRotationMatrix
• From: Gabriel <gnuetzi@xxxxxxxxx>
• Date: Wed, 30 Sep 2015 17:55:36 +0200
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=Ky3K26QbMNYPLWMNWm9bk9bXrWgc27hDbcMW0LUaiQA=; b=KUynJ5sHwksz4I85kwL7ZFC2B6dZ27VOZAgsNdydXxx1au/0NFmXYZuMLGfTGB7sWM 7Ipm8zwPLvm9bbNbU9V1ZqP2BnJVyYjfHpIKq74Te3WdMSTfI3dzCFXYvtjzVSnh4BB6 mErFwohRqQ7xyGXK360uWPUTy55q1ycwlsMTwwtAAhcQZ2+QQcxchLOmkPrtXZhCiYRh glw2hqvWn1VZ6p6nMk/ZS/2rPrms2k5Hg+4QtsrpmolFx7KNgoV5ITf0tYqCkJiyC7NH AyCV18JRAGYiYOfmo8livOXaVbjlCVRlQ8EQ8CQ/YORmJUvXy+NYWkw0poAuhU1k66Xq PuSA==

 But how can that be done , optimize away the division by s approx 1? In certain circumstances, the user normalizes (after integration) some where the quaternion anyway, and does not want to pay for additional division of s? I dont know...? On 09/30/2015 05:47 PM, Dick Lyon wrote: What not always do the latter (the ), 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 wrote: Hello, I have the following suggestions for the function toRotationMatrix()   for the QuaternionBase class: 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 function toRotationMatrix()   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 QuaternionBase<...>::toRotationMatrix() where toRotationMatrix       -> same function as already implemented (user should use this if quaternion is already normalized) toRotationMatrix      -> 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

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