Message Boards Message Boards

2
|
3770 Views
|
2 Replies
|
5 Total Likes
View groups...
Share
Share this post:

EulerAngles very sensitive to precision of real matrix input

Posted 6 years ago

EulerAngles seems to be unusually sensitive to the precision of the input matrix. When matrix elements are not exact numbers.

In[1]:= m = EulerMatrix[{0.52, 1.05, 1.22}]

Out[1]= {{-0.318233, -0.576255, 0.752767}, {0.899929, 0.0660459, 0.431005}, {-0.298086, 0.814597, 0.497571}}

In[2]:= EulerAngles[m]

Out[2]= {0.52, 1.05, 1.22}

As expected. Now round the matrix elements, like if they were typed in:

In[3]:= n = Round[m, 0.000001]

Out[3]= {{-0.318233, -0.576255, 0.752767}, {0.899929, 0.066046, 0.431005}, {-0.298086, 0.814597, 0.497571}}

In[4]:= EulerAngles[n]

During evaluation of In[4]:= EulerAngles::rotm: {{-0.318233,-0.576255,0.752767},{0.899929,0.066046,0.431005},{-0.298086,0.814597,0.497571}} is not a 3 x 3 rotation matrix.

Out[4]= EulerAngles[{{-0.318233, -0.576255, 0.752767}, {0.899929, 
   0.066046, 0.431005}, {-0.298086, 0.814597, 0.497571}}]
POSTED BY: Hans Milton
2 Replies
Posted 6 years ago

Thanks Sander. A less exotic workaround is to orthogonalize the matrix when needed:

m = EulerMatrix@{0.52, 1.05, 1.22}
n = Round[m, 0.000001]

In[3]:= EulerAngles@Orthogonalize@n
Out[3]= {0.52, 1.05, 1.22}
POSTED BY: Hans Milton

Hi Hans,

It checks:

Chop[Det[n] - 1] == 0

which fails for you. If you are confident this is 'ok' (i.e. less stringent than what Chop thinks is 0). You can also call the sub-function directly:

Reverse@AffineTransformsDump`RPYijk[m, {3, 2, 3}]

giving:

{0.52, 1.05, 1.22}
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract