Re: [eigen] precision loss after conversion from rotation matrix to quaternion and back
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] precision loss after conversion from rotation matrix to quaternion and back
• From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
• Date: Mon, 14 May 2012 22:13:30 +0200
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=bDYJN1IMrxNsi/1C9ph+nsDfvcxi7b0HUGBI0X+wPeA=; b=bfWc4eXs+p/wnWDCr/1CdakoI+CXY7SuwfTaOgUym1dDla6h1Lkx01T3m0/1E3CI/P BVOn8pkoirTHUIoFBXD68PUoi43qVlpZkSkplIRavEWEIpbCzLI+LHgy/wZIaIg44mOC Sxfa3i+UI5G7ZK2LQLGa6ihCtJ7PZ23hEZLXqKN3o5ugm7P55v9pB31YcfFFObMiR8WL Yg3ENtx/a+TcKwCKAdKOKc2J1vgU6vsSFoqDHer6XIEIS+qgLdWW3T1SsAhOb+lBzdhx tOqhbUgytYU3RIbYWs7D41qU3PerQlMaU6pCIY9+wdapuw74ilZEfYgXwcel/wiHywTe aELA==

```Hi,

I guess this is because your initial matrix is not perfectly unitary.
You can orthogonalize it with, e.g.:

A = A.householderQr().householderQ();

cheers,
Gael.

On Mon, May 14, 2012 at 9:23 PM, Tobias Langner
<tobias.langner@xxxxxxxxxxxx> wrote:
> Hello all,
>
> So here is my problem:
>
> I have this rotation matrix (Scalar type double):
>
>  0.124564 -0.800873  0.584451
> -0.971925 0.0176983  0.231399
>  -0.19596 -0.597765 -0.777352
>
> Then I convert it to a Quaternion (Scalar type double) using the
> constructor. The quaternion coefficients  (x,y,z,w) are:
> 0.686334 -0.645749 0.14151 -0.302026
>
> Finally I convert the Quaternion back to a rotation matrix using the
> function toRotationMatrix(), which yields a slightly different matrix:
>
>  0.125967  -0.80092  0.584312
> -0.971878 0.0178409  0.231823
> -0.195821 -0.597341 -0.776092
> 0.686334 -0.645749 0.14151 -0.302026
>
> As you can see some numbers differ on the third significant digit, which
> cannot be explained by floating point rounding errors. So where does it come
> from? If I repeat the procedure the rotation matrix will not differ again..
> It changes only on the first forth-and-back conversion.
> I'd appreciate any help.
>
> Best regards,
>
> Tobias
>
>
>
>
>
>

```

• Follow-Ups:

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