{"id":98,"date":"2014-03-27T18:10:25","date_gmt":"2014-03-27T18:10:25","guid":{"rendered":"https:\/\/blogs.scummvm.org\/josejx\/?p=98"},"modified":"2022-05-21T18:15:49","modified_gmt":"2022-05-21T18:15:49","slug":"rotation","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/josejx\/2014\/03\/27\/rotation\/","title":{"rendered":"Rotation!"},"content":{"rendered":"<p><i>Continued from the <a href=\"https:\/\/blogs.scummvm.org\/josejx\/2014\/04\/22\/fixing-attaching-and-detaching-for-good\/\" target=\"_blank\" rel=\"noopener\">previous entry<\/a>.<\/i><br \/>\n<i><\/i><\/p>\n<p>Before digging into the Quaternion implementation, I first inspected the retail version of EMI again to verify its approach to applying the rotation angles.<\/p>\n<p>In the scene <i>&#8216;mig&#8217;<\/i>, I moved Guybrush to the position (1,0,-7) so it was easy to see the result of rotation. Next, I set the rotation to (0,0,0), resulting in the following, which represents our origin pose:<\/p>\n<figure id=\"attachment_100\" aria-describedby=\"caption-attachment-100\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/origin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-100 size-full\" src=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/origin.png\" alt=\"\" width=\"640\" height=\"480\" srcset=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/origin.png 640w, https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/origin-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-100\" class=\"wp-caption-text\">The origin pose for all of the rotation tests<\/figcaption><\/figure>\n<p>To make sure that nothing else is interfering, I&#8217;ll set Guybrush back to this rotation before each operation. Next, I set Guybrush to 90 degrees for each of the rotation angles to determine the name for each principle axis:<\/p>\n<figure id=\"attachment_101\" aria-describedby=\"caption-attachment-101\" style=\"width: 320px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/Rotation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-101\" src=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/Rotation.png\" alt=\"\" width=\"320\" height=\"660\" srcset=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/Rotation.png 320w, https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/Rotation-145x300.png 145w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><figcaption id=\"caption-attachment-101\" class=\"wp-caption-text\">Demonstrating the principle axes<\/figcaption><\/figure>\n<ul>\n<li>guybrush:setrot(90,0,0) &#8211; Pitch (rotation in the Y-Axis)<\/li>\n<li>guybrush:setrot(0,90,0) &#8211; Yaw (rotation in the Z-Axis)<\/li>\n<li>guybrush:setrot(0,0,90) &#8211; Roll (rotation in the X-Axis)<\/li>\n<\/ul>\n<p>We now know which axis is which in the <i>setrot()<\/i> method. Using this information, we&#8217;ll determine what order the rotations are applied by combining the principle rotations:<\/p>\n<figure id=\"attachment_102\" aria-describedby=\"caption-attachment-102\" style=\"width: 320px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/MultiRot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-102\" src=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/MultiRot.png\" alt=\"\" width=\"320\" height=\"880\" srcset=\"https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/MultiRot.png 320w, https:\/\/blogs.scummvm.org\/josejx\/wp-content\/uploads\/sites\/23\/2014\/03\/MultiRot-109x300.png 109w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><figcaption id=\"caption-attachment-102\" class=\"wp-caption-text\">Combined rotations on the principle axes<\/figcaption><\/figure>\n<p>Which is produced by the following rotations:<\/p>\n<ul>\n<li>guybrush:setrot(45,45,0)<\/li>\n<li>guybrush:setrot(0,45,45)<\/li>\n<li>guybrush:setrot(0,45,45)<\/li>\n<li>guybrush:setrot(45,45,45)<\/li>\n<\/ul>\n<p>From this, we can say that the <i>setrot()<\/i> method&#8217;s arguments are definitely Pitch, Yaw, Roll, in that order. From the combined rotations, it appears that the rotations are applied in the order ZXY (by axis). With this information, I can ensure that the Quaternion implementation is using the correct rotation order.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continued from the previous entry. Before digging into the Quaternion implementation, I first inspected the retail version of EMI again to verify its approach to applying the rotation angles. In the scene &#8216;mig&#8217;, I moved Guybrush to the position (1,0,-7) so it was easy to see the result of rotation. Next, I set the rotation [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":2,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/98\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}