Confused about rotation matrices












2














Applying a rotation matrix to a vector means shifting its coordinates to perform the rotation effect.



Applying a rotation matrix to a model at the origin $(0,0,0)$ is not the same at performing a rotation to a model at a translated position, for instance $(2,2,2)$.



The most common way to rotate an object “around its own axis” would be translating to the origin before applying the rotation matrix and then translating back to the previous position:



$$T(x,y,z) * R * T(-x,-y,-z) (P)$$



If you don't, the rotation is not relative to the object's axis, thus lightly misshaped (see picture).



I would like to know if there is a way to directly compute the correct axis-angle representation, simulating a rotation around the own axis of my object in one way, without translating back to origin ?



Also, I red the “gimbal lock” occurs when using Euler angles matrices subsequently, breaking down the process in three rotation matrices for the $X$, $Y$ and $Z$ axes. But what about the axis-angle rotation matrix, which performs the rotation in one step, instead of three:



$$begin{bmatrix} cos theta + {R_x}^2(1 - cos theta) & {R_x}{R_y}(1 - cos theta) - {R_z} sin theta & {R_x}{R_z}(1 - cos theta) + {R_y} sin theta & 0 \ {R_y}{R_x} (1 - cos theta) + {R_z} sin theta & cos theta + {R_y}^2(1 - cos theta) & {R_y}{R_z}(1 - cos theta) - {R_x} sin theta & 0 \ {R_z}{R_x}(1 - cos theta) - {R_y} sin theta & {R_z}{R_y}(1 - cos theta) + {R_x} sin theta & cos theta + {R_z}^2(1 - cos theta) & 0 \ 0 & 0 & 0 & 1 end{bmatrix}$$



Does this kind of matrix prevent the “gimbal lock” ? What is the difference between this matrix and a matrix computed from a quaternion $a + bi + cj + dk$ (using the quaternion multiplication table):



$$begin{bmatrix} a & d & -b & -c\-d & a & c & -b\b & -c & a & -d\c & b & d & a end{bmatrix}$$



Moire pattern










share|cite|improve this question









New contributor




Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    2














    Applying a rotation matrix to a vector means shifting its coordinates to perform the rotation effect.



    Applying a rotation matrix to a model at the origin $(0,0,0)$ is not the same at performing a rotation to a model at a translated position, for instance $(2,2,2)$.



    The most common way to rotate an object “around its own axis” would be translating to the origin before applying the rotation matrix and then translating back to the previous position:



    $$T(x,y,z) * R * T(-x,-y,-z) (P)$$



    If you don't, the rotation is not relative to the object's axis, thus lightly misshaped (see picture).



    I would like to know if there is a way to directly compute the correct axis-angle representation, simulating a rotation around the own axis of my object in one way, without translating back to origin ?



    Also, I red the “gimbal lock” occurs when using Euler angles matrices subsequently, breaking down the process in three rotation matrices for the $X$, $Y$ and $Z$ axes. But what about the axis-angle rotation matrix, which performs the rotation in one step, instead of three:



    $$begin{bmatrix} cos theta + {R_x}^2(1 - cos theta) & {R_x}{R_y}(1 - cos theta) - {R_z} sin theta & {R_x}{R_z}(1 - cos theta) + {R_y} sin theta & 0 \ {R_y}{R_x} (1 - cos theta) + {R_z} sin theta & cos theta + {R_y}^2(1 - cos theta) & {R_y}{R_z}(1 - cos theta) - {R_x} sin theta & 0 \ {R_z}{R_x}(1 - cos theta) - {R_y} sin theta & {R_z}{R_y}(1 - cos theta) + {R_x} sin theta & cos theta + {R_z}^2(1 - cos theta) & 0 \ 0 & 0 & 0 & 1 end{bmatrix}$$



    Does this kind of matrix prevent the “gimbal lock” ? What is the difference between this matrix and a matrix computed from a quaternion $a + bi + cj + dk$ (using the quaternion multiplication table):



    $$begin{bmatrix} a & d & -b & -c\-d & a & c & -b\b & -c & a & -d\c & b & d & a end{bmatrix}$$



    Moire pattern










    share|cite|improve this question









    New contributor




    Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      2












      2








      2







      Applying a rotation matrix to a vector means shifting its coordinates to perform the rotation effect.



      Applying a rotation matrix to a model at the origin $(0,0,0)$ is not the same at performing a rotation to a model at a translated position, for instance $(2,2,2)$.



      The most common way to rotate an object “around its own axis” would be translating to the origin before applying the rotation matrix and then translating back to the previous position:



      $$T(x,y,z) * R * T(-x,-y,-z) (P)$$



      If you don't, the rotation is not relative to the object's axis, thus lightly misshaped (see picture).



      I would like to know if there is a way to directly compute the correct axis-angle representation, simulating a rotation around the own axis of my object in one way, without translating back to origin ?



      Also, I red the “gimbal lock” occurs when using Euler angles matrices subsequently, breaking down the process in three rotation matrices for the $X$, $Y$ and $Z$ axes. But what about the axis-angle rotation matrix, which performs the rotation in one step, instead of three:



      $$begin{bmatrix} cos theta + {R_x}^2(1 - cos theta) & {R_x}{R_y}(1 - cos theta) - {R_z} sin theta & {R_x}{R_z}(1 - cos theta) + {R_y} sin theta & 0 \ {R_y}{R_x} (1 - cos theta) + {R_z} sin theta & cos theta + {R_y}^2(1 - cos theta) & {R_y}{R_z}(1 - cos theta) - {R_x} sin theta & 0 \ {R_z}{R_x}(1 - cos theta) - {R_y} sin theta & {R_z}{R_y}(1 - cos theta) + {R_x} sin theta & cos theta + {R_z}^2(1 - cos theta) & 0 \ 0 & 0 & 0 & 1 end{bmatrix}$$



      Does this kind of matrix prevent the “gimbal lock” ? What is the difference between this matrix and a matrix computed from a quaternion $a + bi + cj + dk$ (using the quaternion multiplication table):



      $$begin{bmatrix} a & d & -b & -c\-d & a & c & -b\b & -c & a & -d\c & b & d & a end{bmatrix}$$



      Moire pattern










      share|cite|improve this question









      New contributor




      Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      Applying a rotation matrix to a vector means shifting its coordinates to perform the rotation effect.



      Applying a rotation matrix to a model at the origin $(0,0,0)$ is not the same at performing a rotation to a model at a translated position, for instance $(2,2,2)$.



      The most common way to rotate an object “around its own axis” would be translating to the origin before applying the rotation matrix and then translating back to the previous position:



      $$T(x,y,z) * R * T(-x,-y,-z) (P)$$



      If you don't, the rotation is not relative to the object's axis, thus lightly misshaped (see picture).



      I would like to know if there is a way to directly compute the correct axis-angle representation, simulating a rotation around the own axis of my object in one way, without translating back to origin ?



      Also, I red the “gimbal lock” occurs when using Euler angles matrices subsequently, breaking down the process in three rotation matrices for the $X$, $Y$ and $Z$ axes. But what about the axis-angle rotation matrix, which performs the rotation in one step, instead of three:



      $$begin{bmatrix} cos theta + {R_x}^2(1 - cos theta) & {R_x}{R_y}(1 - cos theta) - {R_z} sin theta & {R_x}{R_z}(1 - cos theta) + {R_y} sin theta & 0 \ {R_y}{R_x} (1 - cos theta) + {R_z} sin theta & cos theta + {R_y}^2(1 - cos theta) & {R_y}{R_z}(1 - cos theta) - {R_x} sin theta & 0 \ {R_z}{R_x}(1 - cos theta) - {R_y} sin theta & {R_z}{R_y}(1 - cos theta) + {R_x} sin theta & cos theta + {R_z}^2(1 - cos theta) & 0 \ 0 & 0 & 0 & 1 end{bmatrix}$$



      Does this kind of matrix prevent the “gimbal lock” ? What is the difference between this matrix and a matrix computed from a quaternion $a + bi + cj + dk$ (using the quaternion multiplication table):



      $$begin{bmatrix} a & d & -b & -c\-d & a & c & -b\b & -c & a & -d\c & b & d & a end{bmatrix}$$



      Moire pattern







      linear-algebra matrices geometry rotations quaternions






      share|cite|improve this question









      New contributor




      Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|cite|improve this question









      New contributor




      Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|cite|improve this question




      share|cite|improve this question








      edited 2 days ago









      Somos

      13.1k11034




      13.1k11034






      New contributor




      Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      PrionPrion

      113




      113




      New contributor




      Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Prion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          In three dimensions, a $3times 3$ rotation matrix can perform any conceivable rotation you might want upon a vector.



          But a vector by itself has no "location" about which to rotate. It merely changes direction. Even a large collection of vectors still has no "location."



          The fact that you want to rotate a model that has a position means you are dealing with spatial coordinates, not merely vectors.
          One way to deal with spatial coordinates, of course, is to nominate one point in space as the "origin" and identify every point $P$ with the vector from the origin to $P.$
          When you do that, rotations still change the directions of the vectors;
          since we still identify each point by its vector from the origin,
          rotating that vector rotates that point around an axis through the origin.



          This means the origin, which is represented by a zero vector (all coordinates zero), never moves when you apply a $3times 3$ rotation matrix in three dimensions.
          In fact, no matter what $3times 3$ matrix you multiply with the zero vector you still get back the zero vector, even if the matrix does not represent a true rotation.



          If you want to rotate a model around its own center which is not the origin,
          then unless you happen to pick the one rotation axis that also goes through the origin, your rotation will move the origin.
          Hence it is impossible to do with a $3times 3$ matrix.



          What you can do, if you want, is to construct a rotation $R$ by the desired angle around an axis in the desired orientation (parallel to the axis you really want).
          Then if the point $C$ is the center of your object, compute $R(C).$
          Now find the vector $v = C - R(C).$
          Then you can perform the desired rotation of any point $P$ around your object's own center by applying the rotation $R$ and the the translation $T_v$ (adding the vector $v$ to the point's coordinates):
          $$ T_v(R(P)). $$



          Now it's just one translation in addition to the rotation.



          The "axis-angle rotation" matrix you showed, which is a $4times 4$ matrix,
          is actually more than just a rotation matrix, however.
          The way it works is that any point $P$ is represented by a four-coordinate vector,
          begin{bmatrix}
          x_P\ y_P\ z_P\ 1,
          end{bmatrix}

          which you can rotate by multiplying by a matrix in the form you gave;
          but in order to follow the rotation by a translation, you just need to replace the zeros in the right-hand column of your matrix by the coordinates of the translation vector.



          You can also just take the upper left $3times 3$ submatrix of your "axis-angle" matrix and multiply it by the three-coordinate vector from the origin to each point,
          but then it's just a rotation around the origin like any other
          $3times 3$ matrix rotation in three dimensions.



          Whether this avoids "gimbal lock" depends on what you want to do with it.
          If you're actually using it to track the rotation of a three-axis gimbal,
          you can still "lock" the gimbal by putting it through some sequence of axis-angle rotations.
          If you have a free-floating object in space, not an actual gimbal,
          then the way in which "gimbal lock" might apply is if you used a set of Euler angles to represent every orientation of the object relative to its original orientation.
          Some sequence of orientations will force you to suddenly "flip" one of your Euler angles, which is the kind of manipulation that "locks" a real-life gimbal.
          That is, the Euler angles are a kind of fictional gimbal.
          But as long as you don't have a real gimbal or a fictional gimbal,
          you can't "lock" it.





          The difference between matrices and quaternions is an entire question of its own.
          But when they are applied to three-dimensional rotations, each in their own usual way, each is just a different way to represent a rotation.
          And each has its own way of calculating the results of the rotation.
          There is plenty written about either of these techniques that you can study.






          share|cite|improve this answer























          • Thank you for your detailed answer. For the “gimbal lock”, I see what you meant, If I were to use my “one-way” rotation matrix to perform three subsequent rotations in the Euler fashion (to represent a gimbal in a software, for instance), I would lock my gimbal, the solution would be to use quaternions here, no ?
            – Prion
            2 days ago










          • I just don't understand how one rotation performed by one rotation matrix can “lock” the gimbal.
            – Prion
            2 days ago










          • @Prion If you have a three-way gimbal, the object inside has bearings on "top" and "bottom" and the outermost bearings are in fixed places. Rotate the object so that its "top" and "bottom" bearings are aligned with the outermost bearings. Now your gimbal is locked. (That doesn't mean you can't rotate it any more, it just means the initial direction of rotation is limited.)
            – David K
            2 days ago












          • The only “real” danger of gimbal lock for a mathematical application would be a camera or a plane (like in 3D games) that you could rotate subsequently, if you happen to rotate in “one-way” matrix instead of three subsequent rotations, then there is no danger for that.
            – Prion
            2 days ago










          • As I said, if there's no gimbal, there's no possibility of gimbal lock. So all you need to do is figure out whether your application has a gimbal (real or imaginary). If you're rotating a free body with a single matrix for each rotation, I agree there's no gimbal and no gimbal lock.
            – David K
            2 days ago











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Prion is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3063022%2fconfused-about-rotation-matrices%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          In three dimensions, a $3times 3$ rotation matrix can perform any conceivable rotation you might want upon a vector.



          But a vector by itself has no "location" about which to rotate. It merely changes direction. Even a large collection of vectors still has no "location."



          The fact that you want to rotate a model that has a position means you are dealing with spatial coordinates, not merely vectors.
          One way to deal with spatial coordinates, of course, is to nominate one point in space as the "origin" and identify every point $P$ with the vector from the origin to $P.$
          When you do that, rotations still change the directions of the vectors;
          since we still identify each point by its vector from the origin,
          rotating that vector rotates that point around an axis through the origin.



          This means the origin, which is represented by a zero vector (all coordinates zero), never moves when you apply a $3times 3$ rotation matrix in three dimensions.
          In fact, no matter what $3times 3$ matrix you multiply with the zero vector you still get back the zero vector, even if the matrix does not represent a true rotation.



          If you want to rotate a model around its own center which is not the origin,
          then unless you happen to pick the one rotation axis that also goes through the origin, your rotation will move the origin.
          Hence it is impossible to do with a $3times 3$ matrix.



          What you can do, if you want, is to construct a rotation $R$ by the desired angle around an axis in the desired orientation (parallel to the axis you really want).
          Then if the point $C$ is the center of your object, compute $R(C).$
          Now find the vector $v = C - R(C).$
          Then you can perform the desired rotation of any point $P$ around your object's own center by applying the rotation $R$ and the the translation $T_v$ (adding the vector $v$ to the point's coordinates):
          $$ T_v(R(P)). $$



          Now it's just one translation in addition to the rotation.



          The "axis-angle rotation" matrix you showed, which is a $4times 4$ matrix,
          is actually more than just a rotation matrix, however.
          The way it works is that any point $P$ is represented by a four-coordinate vector,
          begin{bmatrix}
          x_P\ y_P\ z_P\ 1,
          end{bmatrix}

          which you can rotate by multiplying by a matrix in the form you gave;
          but in order to follow the rotation by a translation, you just need to replace the zeros in the right-hand column of your matrix by the coordinates of the translation vector.



          You can also just take the upper left $3times 3$ submatrix of your "axis-angle" matrix and multiply it by the three-coordinate vector from the origin to each point,
          but then it's just a rotation around the origin like any other
          $3times 3$ matrix rotation in three dimensions.



          Whether this avoids "gimbal lock" depends on what you want to do with it.
          If you're actually using it to track the rotation of a three-axis gimbal,
          you can still "lock" the gimbal by putting it through some sequence of axis-angle rotations.
          If you have a free-floating object in space, not an actual gimbal,
          then the way in which "gimbal lock" might apply is if you used a set of Euler angles to represent every orientation of the object relative to its original orientation.
          Some sequence of orientations will force you to suddenly "flip" one of your Euler angles, which is the kind of manipulation that "locks" a real-life gimbal.
          That is, the Euler angles are a kind of fictional gimbal.
          But as long as you don't have a real gimbal or a fictional gimbal,
          you can't "lock" it.





          The difference between matrices and quaternions is an entire question of its own.
          But when they are applied to three-dimensional rotations, each in their own usual way, each is just a different way to represent a rotation.
          And each has its own way of calculating the results of the rotation.
          There is plenty written about either of these techniques that you can study.






          share|cite|improve this answer























          • Thank you for your detailed answer. For the “gimbal lock”, I see what you meant, If I were to use my “one-way” rotation matrix to perform three subsequent rotations in the Euler fashion (to represent a gimbal in a software, for instance), I would lock my gimbal, the solution would be to use quaternions here, no ?
            – Prion
            2 days ago










          • I just don't understand how one rotation performed by one rotation matrix can “lock” the gimbal.
            – Prion
            2 days ago










          • @Prion If you have a three-way gimbal, the object inside has bearings on "top" and "bottom" and the outermost bearings are in fixed places. Rotate the object so that its "top" and "bottom" bearings are aligned with the outermost bearings. Now your gimbal is locked. (That doesn't mean you can't rotate it any more, it just means the initial direction of rotation is limited.)
            – David K
            2 days ago












          • The only “real” danger of gimbal lock for a mathematical application would be a camera or a plane (like in 3D games) that you could rotate subsequently, if you happen to rotate in “one-way” matrix instead of three subsequent rotations, then there is no danger for that.
            – Prion
            2 days ago










          • As I said, if there's no gimbal, there's no possibility of gimbal lock. So all you need to do is figure out whether your application has a gimbal (real or imaginary). If you're rotating a free body with a single matrix for each rotation, I agree there's no gimbal and no gimbal lock.
            – David K
            2 days ago
















          0














          In three dimensions, a $3times 3$ rotation matrix can perform any conceivable rotation you might want upon a vector.



          But a vector by itself has no "location" about which to rotate. It merely changes direction. Even a large collection of vectors still has no "location."



          The fact that you want to rotate a model that has a position means you are dealing with spatial coordinates, not merely vectors.
          One way to deal with spatial coordinates, of course, is to nominate one point in space as the "origin" and identify every point $P$ with the vector from the origin to $P.$
          When you do that, rotations still change the directions of the vectors;
          since we still identify each point by its vector from the origin,
          rotating that vector rotates that point around an axis through the origin.



          This means the origin, which is represented by a zero vector (all coordinates zero), never moves when you apply a $3times 3$ rotation matrix in three dimensions.
          In fact, no matter what $3times 3$ matrix you multiply with the zero vector you still get back the zero vector, even if the matrix does not represent a true rotation.



          If you want to rotate a model around its own center which is not the origin,
          then unless you happen to pick the one rotation axis that also goes through the origin, your rotation will move the origin.
          Hence it is impossible to do with a $3times 3$ matrix.



          What you can do, if you want, is to construct a rotation $R$ by the desired angle around an axis in the desired orientation (parallel to the axis you really want).
          Then if the point $C$ is the center of your object, compute $R(C).$
          Now find the vector $v = C - R(C).$
          Then you can perform the desired rotation of any point $P$ around your object's own center by applying the rotation $R$ and the the translation $T_v$ (adding the vector $v$ to the point's coordinates):
          $$ T_v(R(P)). $$



          Now it's just one translation in addition to the rotation.



          The "axis-angle rotation" matrix you showed, which is a $4times 4$ matrix,
          is actually more than just a rotation matrix, however.
          The way it works is that any point $P$ is represented by a four-coordinate vector,
          begin{bmatrix}
          x_P\ y_P\ z_P\ 1,
          end{bmatrix}

          which you can rotate by multiplying by a matrix in the form you gave;
          but in order to follow the rotation by a translation, you just need to replace the zeros in the right-hand column of your matrix by the coordinates of the translation vector.



          You can also just take the upper left $3times 3$ submatrix of your "axis-angle" matrix and multiply it by the three-coordinate vector from the origin to each point,
          but then it's just a rotation around the origin like any other
          $3times 3$ matrix rotation in three dimensions.



          Whether this avoids "gimbal lock" depends on what you want to do with it.
          If you're actually using it to track the rotation of a three-axis gimbal,
          you can still "lock" the gimbal by putting it through some sequence of axis-angle rotations.
          If you have a free-floating object in space, not an actual gimbal,
          then the way in which "gimbal lock" might apply is if you used a set of Euler angles to represent every orientation of the object relative to its original orientation.
          Some sequence of orientations will force you to suddenly "flip" one of your Euler angles, which is the kind of manipulation that "locks" a real-life gimbal.
          That is, the Euler angles are a kind of fictional gimbal.
          But as long as you don't have a real gimbal or a fictional gimbal,
          you can't "lock" it.





          The difference between matrices and quaternions is an entire question of its own.
          But when they are applied to three-dimensional rotations, each in their own usual way, each is just a different way to represent a rotation.
          And each has its own way of calculating the results of the rotation.
          There is plenty written about either of these techniques that you can study.






          share|cite|improve this answer























          • Thank you for your detailed answer. For the “gimbal lock”, I see what you meant, If I were to use my “one-way” rotation matrix to perform three subsequent rotations in the Euler fashion (to represent a gimbal in a software, for instance), I would lock my gimbal, the solution would be to use quaternions here, no ?
            – Prion
            2 days ago










          • I just don't understand how one rotation performed by one rotation matrix can “lock” the gimbal.
            – Prion
            2 days ago










          • @Prion If you have a three-way gimbal, the object inside has bearings on "top" and "bottom" and the outermost bearings are in fixed places. Rotate the object so that its "top" and "bottom" bearings are aligned with the outermost bearings. Now your gimbal is locked. (That doesn't mean you can't rotate it any more, it just means the initial direction of rotation is limited.)
            – David K
            2 days ago












          • The only “real” danger of gimbal lock for a mathematical application would be a camera or a plane (like in 3D games) that you could rotate subsequently, if you happen to rotate in “one-way” matrix instead of three subsequent rotations, then there is no danger for that.
            – Prion
            2 days ago










          • As I said, if there's no gimbal, there's no possibility of gimbal lock. So all you need to do is figure out whether your application has a gimbal (real or imaginary). If you're rotating a free body with a single matrix for each rotation, I agree there's no gimbal and no gimbal lock.
            – David K
            2 days ago














          0












          0








          0






          In three dimensions, a $3times 3$ rotation matrix can perform any conceivable rotation you might want upon a vector.



          But a vector by itself has no "location" about which to rotate. It merely changes direction. Even a large collection of vectors still has no "location."



          The fact that you want to rotate a model that has a position means you are dealing with spatial coordinates, not merely vectors.
          One way to deal with spatial coordinates, of course, is to nominate one point in space as the "origin" and identify every point $P$ with the vector from the origin to $P.$
          When you do that, rotations still change the directions of the vectors;
          since we still identify each point by its vector from the origin,
          rotating that vector rotates that point around an axis through the origin.



          This means the origin, which is represented by a zero vector (all coordinates zero), never moves when you apply a $3times 3$ rotation matrix in three dimensions.
          In fact, no matter what $3times 3$ matrix you multiply with the zero vector you still get back the zero vector, even if the matrix does not represent a true rotation.



          If you want to rotate a model around its own center which is not the origin,
          then unless you happen to pick the one rotation axis that also goes through the origin, your rotation will move the origin.
          Hence it is impossible to do with a $3times 3$ matrix.



          What you can do, if you want, is to construct a rotation $R$ by the desired angle around an axis in the desired orientation (parallel to the axis you really want).
          Then if the point $C$ is the center of your object, compute $R(C).$
          Now find the vector $v = C - R(C).$
          Then you can perform the desired rotation of any point $P$ around your object's own center by applying the rotation $R$ and the the translation $T_v$ (adding the vector $v$ to the point's coordinates):
          $$ T_v(R(P)). $$



          Now it's just one translation in addition to the rotation.



          The "axis-angle rotation" matrix you showed, which is a $4times 4$ matrix,
          is actually more than just a rotation matrix, however.
          The way it works is that any point $P$ is represented by a four-coordinate vector,
          begin{bmatrix}
          x_P\ y_P\ z_P\ 1,
          end{bmatrix}

          which you can rotate by multiplying by a matrix in the form you gave;
          but in order to follow the rotation by a translation, you just need to replace the zeros in the right-hand column of your matrix by the coordinates of the translation vector.



          You can also just take the upper left $3times 3$ submatrix of your "axis-angle" matrix and multiply it by the three-coordinate vector from the origin to each point,
          but then it's just a rotation around the origin like any other
          $3times 3$ matrix rotation in three dimensions.



          Whether this avoids "gimbal lock" depends on what you want to do with it.
          If you're actually using it to track the rotation of a three-axis gimbal,
          you can still "lock" the gimbal by putting it through some sequence of axis-angle rotations.
          If you have a free-floating object in space, not an actual gimbal,
          then the way in which "gimbal lock" might apply is if you used a set of Euler angles to represent every orientation of the object relative to its original orientation.
          Some sequence of orientations will force you to suddenly "flip" one of your Euler angles, which is the kind of manipulation that "locks" a real-life gimbal.
          That is, the Euler angles are a kind of fictional gimbal.
          But as long as you don't have a real gimbal or a fictional gimbal,
          you can't "lock" it.





          The difference between matrices and quaternions is an entire question of its own.
          But when they are applied to three-dimensional rotations, each in their own usual way, each is just a different way to represent a rotation.
          And each has its own way of calculating the results of the rotation.
          There is plenty written about either of these techniques that you can study.






          share|cite|improve this answer














          In three dimensions, a $3times 3$ rotation matrix can perform any conceivable rotation you might want upon a vector.



          But a vector by itself has no "location" about which to rotate. It merely changes direction. Even a large collection of vectors still has no "location."



          The fact that you want to rotate a model that has a position means you are dealing with spatial coordinates, not merely vectors.
          One way to deal with spatial coordinates, of course, is to nominate one point in space as the "origin" and identify every point $P$ with the vector from the origin to $P.$
          When you do that, rotations still change the directions of the vectors;
          since we still identify each point by its vector from the origin,
          rotating that vector rotates that point around an axis through the origin.



          This means the origin, which is represented by a zero vector (all coordinates zero), never moves when you apply a $3times 3$ rotation matrix in three dimensions.
          In fact, no matter what $3times 3$ matrix you multiply with the zero vector you still get back the zero vector, even if the matrix does not represent a true rotation.



          If you want to rotate a model around its own center which is not the origin,
          then unless you happen to pick the one rotation axis that also goes through the origin, your rotation will move the origin.
          Hence it is impossible to do with a $3times 3$ matrix.



          What you can do, if you want, is to construct a rotation $R$ by the desired angle around an axis in the desired orientation (parallel to the axis you really want).
          Then if the point $C$ is the center of your object, compute $R(C).$
          Now find the vector $v = C - R(C).$
          Then you can perform the desired rotation of any point $P$ around your object's own center by applying the rotation $R$ and the the translation $T_v$ (adding the vector $v$ to the point's coordinates):
          $$ T_v(R(P)). $$



          Now it's just one translation in addition to the rotation.



          The "axis-angle rotation" matrix you showed, which is a $4times 4$ matrix,
          is actually more than just a rotation matrix, however.
          The way it works is that any point $P$ is represented by a four-coordinate vector,
          begin{bmatrix}
          x_P\ y_P\ z_P\ 1,
          end{bmatrix}

          which you can rotate by multiplying by a matrix in the form you gave;
          but in order to follow the rotation by a translation, you just need to replace the zeros in the right-hand column of your matrix by the coordinates of the translation vector.



          You can also just take the upper left $3times 3$ submatrix of your "axis-angle" matrix and multiply it by the three-coordinate vector from the origin to each point,
          but then it's just a rotation around the origin like any other
          $3times 3$ matrix rotation in three dimensions.



          Whether this avoids "gimbal lock" depends on what you want to do with it.
          If you're actually using it to track the rotation of a three-axis gimbal,
          you can still "lock" the gimbal by putting it through some sequence of axis-angle rotations.
          If you have a free-floating object in space, not an actual gimbal,
          then the way in which "gimbal lock" might apply is if you used a set of Euler angles to represent every orientation of the object relative to its original orientation.
          Some sequence of orientations will force you to suddenly "flip" one of your Euler angles, which is the kind of manipulation that "locks" a real-life gimbal.
          That is, the Euler angles are a kind of fictional gimbal.
          But as long as you don't have a real gimbal or a fictional gimbal,
          you can't "lock" it.





          The difference between matrices and quaternions is an entire question of its own.
          But when they are applied to three-dimensional rotations, each in their own usual way, each is just a different way to represent a rotation.
          And each has its own way of calculating the results of the rotation.
          There is plenty written about either of these techniques that you can study.







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited 2 days ago

























          answered 2 days ago









          David KDavid K

          52.7k340115




          52.7k340115












          • Thank you for your detailed answer. For the “gimbal lock”, I see what you meant, If I were to use my “one-way” rotation matrix to perform three subsequent rotations in the Euler fashion (to represent a gimbal in a software, for instance), I would lock my gimbal, the solution would be to use quaternions here, no ?
            – Prion
            2 days ago










          • I just don't understand how one rotation performed by one rotation matrix can “lock” the gimbal.
            – Prion
            2 days ago










          • @Prion If you have a three-way gimbal, the object inside has bearings on "top" and "bottom" and the outermost bearings are in fixed places. Rotate the object so that its "top" and "bottom" bearings are aligned with the outermost bearings. Now your gimbal is locked. (That doesn't mean you can't rotate it any more, it just means the initial direction of rotation is limited.)
            – David K
            2 days ago












          • The only “real” danger of gimbal lock for a mathematical application would be a camera or a plane (like in 3D games) that you could rotate subsequently, if you happen to rotate in “one-way” matrix instead of three subsequent rotations, then there is no danger for that.
            – Prion
            2 days ago










          • As I said, if there's no gimbal, there's no possibility of gimbal lock. So all you need to do is figure out whether your application has a gimbal (real or imaginary). If you're rotating a free body with a single matrix for each rotation, I agree there's no gimbal and no gimbal lock.
            – David K
            2 days ago


















          • Thank you for your detailed answer. For the “gimbal lock”, I see what you meant, If I were to use my “one-way” rotation matrix to perform three subsequent rotations in the Euler fashion (to represent a gimbal in a software, for instance), I would lock my gimbal, the solution would be to use quaternions here, no ?
            – Prion
            2 days ago










          • I just don't understand how one rotation performed by one rotation matrix can “lock” the gimbal.
            – Prion
            2 days ago










          • @Prion If you have a three-way gimbal, the object inside has bearings on "top" and "bottom" and the outermost bearings are in fixed places. Rotate the object so that its "top" and "bottom" bearings are aligned with the outermost bearings. Now your gimbal is locked. (That doesn't mean you can't rotate it any more, it just means the initial direction of rotation is limited.)
            – David K
            2 days ago












          • The only “real” danger of gimbal lock for a mathematical application would be a camera or a plane (like in 3D games) that you could rotate subsequently, if you happen to rotate in “one-way” matrix instead of three subsequent rotations, then there is no danger for that.
            – Prion
            2 days ago










          • As I said, if there's no gimbal, there's no possibility of gimbal lock. So all you need to do is figure out whether your application has a gimbal (real or imaginary). If you're rotating a free body with a single matrix for each rotation, I agree there's no gimbal and no gimbal lock.
            – David K
            2 days ago
















          Thank you for your detailed answer. For the “gimbal lock”, I see what you meant, If I were to use my “one-way” rotation matrix to perform three subsequent rotations in the Euler fashion (to represent a gimbal in a software, for instance), I would lock my gimbal, the solution would be to use quaternions here, no ?
          – Prion
          2 days ago




          Thank you for your detailed answer. For the “gimbal lock”, I see what you meant, If I were to use my “one-way” rotation matrix to perform three subsequent rotations in the Euler fashion (to represent a gimbal in a software, for instance), I would lock my gimbal, the solution would be to use quaternions here, no ?
          – Prion
          2 days ago












          I just don't understand how one rotation performed by one rotation matrix can “lock” the gimbal.
          – Prion
          2 days ago




          I just don't understand how one rotation performed by one rotation matrix can “lock” the gimbal.
          – Prion
          2 days ago












          @Prion If you have a three-way gimbal, the object inside has bearings on "top" and "bottom" and the outermost bearings are in fixed places. Rotate the object so that its "top" and "bottom" bearings are aligned with the outermost bearings. Now your gimbal is locked. (That doesn't mean you can't rotate it any more, it just means the initial direction of rotation is limited.)
          – David K
          2 days ago






          @Prion If you have a three-way gimbal, the object inside has bearings on "top" and "bottom" and the outermost bearings are in fixed places. Rotate the object so that its "top" and "bottom" bearings are aligned with the outermost bearings. Now your gimbal is locked. (That doesn't mean you can't rotate it any more, it just means the initial direction of rotation is limited.)
          – David K
          2 days ago














          The only “real” danger of gimbal lock for a mathematical application would be a camera or a plane (like in 3D games) that you could rotate subsequently, if you happen to rotate in “one-way” matrix instead of three subsequent rotations, then there is no danger for that.
          – Prion
          2 days ago




          The only “real” danger of gimbal lock for a mathematical application would be a camera or a plane (like in 3D games) that you could rotate subsequently, if you happen to rotate in “one-way” matrix instead of three subsequent rotations, then there is no danger for that.
          – Prion
          2 days ago












          As I said, if there's no gimbal, there's no possibility of gimbal lock. So all you need to do is figure out whether your application has a gimbal (real or imaginary). If you're rotating a free body with a single matrix for each rotation, I agree there's no gimbal and no gimbal lock.
          – David K
          2 days ago




          As I said, if there's no gimbal, there's no possibility of gimbal lock. So all you need to do is figure out whether your application has a gimbal (real or imaginary). If you're rotating a free body with a single matrix for each rotation, I agree there's no gimbal and no gimbal lock.
          – David K
          2 days ago










          Prion is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Prion is a new contributor. Be nice, and check out our Code of Conduct.













          Prion is a new contributor. Be nice, and check out our Code of Conduct.












          Prion is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3063022%2fconfused-about-rotation-matrices%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mario Kart Wii

          What does “Dominus providebit” mean?

          Antonio Litta Visconti Arese