## Re: [cgkit-user] toEulerXYZ ()

 Re: [cgkit-user] toEulerXYZ () From: Matthias Baas - 2008-08-25 15:20:43 ```Hi, just to let you know, I have replaced the toEuler*() methods with a more robust and (hopefully) correct version. Instead of my rather naive approach from before, I'm now using the algorithm from the comp.graphics.algorithms FAQ: http://www.cgafaq.info/wiki/Euler_angles_from_matrix I have also updated the unit tests to include cases like below, so let's hope that I got it right this time. In the example from below, the result is now -60 (which is equivalent to 300) instead of 60. The code is in svn, so if you are in a position to compile the package yourself, I would appreciate if you could give it a try. Cheers, - Matthias - Myrek wrote: > I wanted to use the toEulerXYZ () and probably wrong acts. > First rotate "podstawa1" axis of 300 degrees so as: > > podstawa1.rot = mat3.fromEulerXYZ (0, 0, radians (300)) > > and it's ok: > > >>> Podstawa1.rot > (0.5, 0.866025, 0) > (-0.866025, 0.5, 0) > (0, 0, 1) > > But I wants back to read about how many degrees is rotate: > > >>> ile = degrees (podstawa1.rot.toEulerXYZ () [2]) > >>> Print ile > 60.0 > > Provides 60 instead of 300, why? You can see that the function > toEulerXYZ () calculates 180 - (300-180) = 60, why? How to correctly > read the angle of rotation over 180 degrees? The toEulerXYZ () reads > correctly only up to 180 degrees. > > Thx. > Myrek ```

 [cgkit-user] toEulerXYZ () From: Myrek - 2008-08-18 08:38:20 Attachments: Message as HTML ```I wanted to use the toEulerXYZ () and probably wrong acts. First rotate "podstawa1" axis of 300 degrees so as: podstawa1.rot = mat3.fromEulerXYZ (0, 0, radians (300)) and it's ok: >>> Podstawa1.rot (0.5, 0.866025, 0) (-0.866025, 0.5, 0) (0, 0, 1) But I wants back to read about how many degrees is rotate: >>> ile = degrees (podstawa1.rot.toEulerXYZ () [2]) >>> Print ile 60.0 Provides 60 instead of 300, why? You can see that the function toEulerXYZ () calculates 180 - (300-180) = 60, why? How to correctly read the angle of rotation over 180 degrees? The toEulerXYZ () reads correctly only up to 180 degrees. Thx. Myrek ```
 Re: [cgkit-user] toEulerXYZ () From: Matthias Baas - 2008-08-19 21:22:16 ```Myrek wrote: > podstawa1.rot = mat3.fromEulerXYZ (0, 0, radians (300)) > > and it's ok: > > >>> Podstawa1.rot > (0.5, 0.866025, 0) > (-0.866025, 0.5, 0) > (0, 0, 1) > > But I wants back to read about how many degrees is rotate: > > >>> ile = degrees (podstawa1.rot.toEulerXYZ () [2]) > >>> Print ile > 60.0 > > Provides 60 instead of 300, why? Well, because there is a bug in the code (or rather, I have been too naive when writing that code). Thanks for reporting this! I will look into it. Having said that, note that in general, it is not guaranteed that toEuler*() will return exactly the same values as you were using for constructing the matrix. It will only return values that would produce the same matrix again (which currently is not the case because of that bug). In the above case, you might probably get -60 instead of 300. In the general case, you may also get an entirely different set of angles that just happens to describe the same rotation. So if your application needs to be able to extract the original angles again, you may be better off storing them explicitly somewhere. - Matthias - ```
 Re: [cgkit-user] toEulerXYZ () From: Matthias Baas - 2008-08-25 15:20:43 ```Hi, just to let you know, I have replaced the toEuler*() methods with a more robust and (hopefully) correct version. Instead of my rather naive approach from before, I'm now using the algorithm from the comp.graphics.algorithms FAQ: http://www.cgafaq.info/wiki/Euler_angles_from_matrix I have also updated the unit tests to include cases like below, so let's hope that I got it right this time. In the example from below, the result is now -60 (which is equivalent to 300) instead of 60. The code is in svn, so if you are in a position to compile the package yourself, I would appreciate if you could give it a try. Cheers, - Matthias - Myrek wrote: > I wanted to use the toEulerXYZ () and probably wrong acts. > First rotate "podstawa1" axis of 300 degrees so as: > > podstawa1.rot = mat3.fromEulerXYZ (0, 0, radians (300)) > > and it's ok: > > >>> Podstawa1.rot > (0.5, 0.866025, 0) > (-0.866025, 0.5, 0) > (0, 0, 1) > > But I wants back to read about how many degrees is rotate: > > >>> ile = degrees (podstawa1.rot.toEulerXYZ () [2]) > >>> Print ile > 60.0 > > Provides 60 instead of 300, why? You can see that the function > toEulerXYZ () calculates 180 - (300-180) = 60, why? How to correctly > read the angle of rotation over 180 degrees? The toEulerXYZ () reads > correctly only up to 180 degrees. > > Thx. > Myrek ```