{"id":61,"date":"2013-11-08T15:46:23","date_gmt":"2013-11-08T15:46:23","guid":{"rendered":"\/\/3dbym.ru\/2013\/11\/converting-between-euler-angles-and-quaternions\/"},"modified":"2013-11-08T15:46:23","modified_gmt":"2013-11-08T15:46:23","slug":"converting-between-euler-angles-and-quaternions","status":"publish","type":"post","link":"https:\/\/3dbym.ru\/2013\/11\/converting-between-euler-angles-and-quaternions\/","title":{"rendered":"Converting Between Euler Angles and Quaternions"},"content":{"rendered":"

There is one huge reason that conversion between Euler angles and quaternions is necessary\u2014ease of use. Because it is impossible to visualize a quaternion, it is very hard to enter one into a program. If a modeling program wants you to input a rotation value for an object, it would be considerably easier to enter three Euler angles rather than to enter a quaternion.<\/p>\n

To convert a set of Euler angles to a quaternion, you first must convert each angle to its own quaternion. This is done using one of three formu\u00adlas, depending on which axis your rotation is around. AH three formulas are shown in the second part of Figure 2.6. To create a final quaternion, all you have to do is multiply the three previous quaternions.<\/p>\n

<\/p>\n

<\/p>\n\n\n
\n

\"Converting<\/p>\n<\/td>\n<\/tr>\n<\/table>\n

qro\/\/=[cos(-|-) sin(-|-) 0 \u00b0] QP\/te\/, = [cos(-^-) \u00b0 sin(-^-) o] <\/a>Qyaw = [cos^-~^ 0 0 sin(-^-)]<\/p>\n\n\n
\n

Qfinal \u2014<\/p>\n<\/td>\n<\/tr>\n<\/table>\n

QyawQpitchQroll<\/p>\n

Figure 2.6 Left:A representation of Euler angles. Right: Converting the three Euler angles into quaternions.<\/p>\n

When you are ready to convert a quaternion, you must call on the miracle of quaternion to matrix conversion. Before you can do any\u00adthing else, you must calculate certain elements of the rotation matrix, which will later be used to extract the angles.<\/p>\n

<\/p>\n

The elements you need to calculate are mil, m21, m31, m32, and m33. Let\u2019s review how to acquire those five elements from a quaternion.<\/p>\n

m11 = w2 + x2 — y2 — z2<\/p>\n

m21 = 2xy + 2wz<\/p>\n

m31 = 2xz — 2wy<\/p>\n

m32 = 2yx + 2wx<\/p>\n

m33 = w2 — x2 — y2 + z2<\/p>\n

Now all that is left is to extract the angles. Once those figures are calcu\u00adlated, you can extract the Euler angles using the following formulas:<\/p>\n

roll = arctan ( 17)32 )<\/p>\n

\u0442\u0437\u0437<\/a> J<\/p>\n

pitch = arcsin(- m31) yaw= arctan<\/p>\n

These formulas are very useful. Most people would balk if a program displayed quaternions instead of Euler angles to represent a rotation.<\/p>\n

They would be much happier to simply see the three direction angles instead because they can visualize the rotation much easier. With these equations you can still appreciate all the advantages of quaternions without driving away the people using your program.<\/p>\n","protected":false},"excerpt":{"rendered":"

There is one huge reason that conversion between Euler angles and quaternions is necessary\u2014ease of use. Because it is impossible to visualize a quaternion, it is very hard to enter one into a program. If a modeling program wants you to input a rotation value for an object, it would be considerably easier to enter […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/posts\/61"}],"collection":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":0,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"wp:attachment":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}