🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Euler Angles To Matrix

Started by
4 comments, last by recp 6 years, 3 months ago

I want to implement XYZ, XZY, YXZ, YZX, ZXY, ZYX intrinsic Tait-Bryan rotations to matrix (Right Hand),
So I implemented formulas in this PDF: https://www.geometrictools.com/Documentation/EulerAngles.pdf

The problem is that some formulas (or components) appears to be different in wikipedia: https://en.wikipedia.org/wiki/Euler_angles
See the "Rotation matrix" section and XZY order. XYZ seems same.

Wikipedia version used s1s3 + c1c3s2 but the PDF used sxsy + cxcysz for m01, −s2 in wiki −sz in PDF for m10...  

I'm confused :(

Does anyone know which one is correct?
Thanks

Advertisement

I'm not going to go through those formulas if I am not being paid for it. But you can easily set up an example and see which one matches.

EDIT: You can also ask WolframAlpha to do the computations for you: http://www.wolframalpha.com/input/?i=[[cos(a),sin(a),0],[-sin(a),cos(a),0],[0,0,1]]*[[1,0,0],[0,cos(b),sin(b)],[0,-sin(b),cos(b)]]*[[cos(c),sin(c),0],[-sin(c),cos(c),0],[0,0,1]]

@alvaro thanks for sharing it, I'll check it asap.

Also I found this: https://en.wikipedia.org/wiki/Rotation_matrix (General rotations)

Quote

R = Rz ( α ) Ry ( β ) Rx ( γ ) intrinsics rotations about axes z, y, x

R = Rz ( γ ) Ry ( β ) Rx ( α ) extrinsic rotations about axes x, y, z

I'm not sure reversing the order like RzRyRx to RxRyRz will give reverse intrinsics rotation (ZYX -> XYZ)
I will try this multiplication with wolframalpha tool and compare result matrices with wiki and that reference PDF

I tested all orders (XYZ, XZY, YZX, YXZ, ZXY, ZYX) with wolframalpha tool it seems PDF version is correct, XZY matrix:

http://www.wolframalpha.com/input/?i=[[1,0,0],[0,cos(x),-sin(x)],[0,sin(x),cos(x)]]*[[cos(z),+-sin(z),0],[sin(z),cos(z),0],[0,0,1]]*[[cos(y),0,sin(y)],[0,1,0],[-sin(y),0,cos(y)]]

As I mentioned in first post, some matrix components seem different on Wikipedia.
FWIW, my implementation can be found at: https://github.com/recp/cglm

EDIT:

It seems Wikipedia version also correct, it is all about different naming conventions.
For Z1 X2 Y3 rotation I think c2c3 means cxcy, it seems like they used order index here:

Quote

1, 2, 3 represent the angles α, β and γ, i.e. the angles corresponding to the first, second and third elemental rotations respectively.

now everything is clear.

This topic is closed to new replies.

Advertisement