Calculate 3d Rotation Maintaining Orientation











up vote
2
down vote

favorite












My Current Setup:



Let's assume we have these 3 axes in 3d space.



3D Axes
Let's also assume that x = blue; y = red; green = z;



To calculate a rotation on the x axis, i.e., from point A->E, we can calculate that by doing



p1 = A
p2 = Origin (Gray)
p3 = E


XAngleInRads Formula



This would also work for A->C, however, to get the circular behavior we want, we need to do



enter image description here



All of this works great :)



Now for,



The Problem:



So far, I have my X-Axis Rotation down perfectly. I am looking to rotate the Y and Z axis in such a manner that I NEVER rotate the INITIAL Z axis.



Let's say I have 2 objects, object O and object P as noted on the picture.
The goal is that as O translates and rotates, that P will only rotate to face O. However, we do NOT want the orientation of P to follow the orientation of O.



Test Cases:



Assume all rotations occur from Origin, so if we rotate O, then it moves. If we rotate P, it just turns.



Let's start O at position A and P at position Origin. If we orient (rotate about Z) by 90 degrees, we do NOT want P to move.



O Rotation (0, 0, 90) -- P Rotation (0, 0, 0)



Let's now rotate O from position A->E.



O Rotation (-90, 0, 0) -- P Rotation (-90, 0, 0)



Now, let's go from E-> B. This is a rotation about the Z axis, but we DO want to move, because if we rotate the orientation of O, it is not the Y axis that we do NOT want to rotate.



O Rotation (-90, 0, 90) -- P Rotation (-90, 0, 90)



Now let's get back to point A by reversing the rotations.



O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



Now let's rotate A->B but also rotate O 90 degrees about Z. Because the rotation orientation is now back to the Z axis, we do NOT want P to rotate about the Z. So we have



O Rotation (0, 90, 90) -- P Rotation (0, 90, 0).



Let's go back to point A



O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



Now, let's go 45 degrees from A->E so we have



O Rotation (45, 0, 0) -- P Rotation (45, 0, 0)



Now rotate from currentPosition->B. This rotation requires that part of Z and part of Y are both part of orientation. It is half. So, we don't rotate both Y or Z by 90 degrees, we rotate each by 45 degrees, since it X rotation is in between Y and Z axis.



O Rotation (45, 45, 45) -- P Rotation (45, 45, 45)



Final Problem:



So, I am in search of a formula to help me keep the "Initial Z Axis" locked, such that the orientation of P never changes at any rotation of X, Y, Z. You can see that I cannot just lock the Z axis for orientation, as at 90 and 270 degrees, the Z axis then becomes the Y axis, in terms of orientation. Any help in creating a formula as to rotate object O and P such that P rotates to follow O, however, if O rotates about orientation (spin), that P does not follow.



Edit1:



I have come up with the ratio of how much y (yRatio) and how much z (zRatio) according to the current xAngleInRadians. I'm just not sure what to do with these variables. I just know how much of Z and how much of Y we WANT to rotate. If O is at A, then we want 0(zero) Z rotation. If O is at E, then we want 0(zero) Y rotation. However, if O is 45 degrees between A and E, then we want 1/2 rotation for Y and Z.



(ZRatio, YRatio) for picture sake.



Ratio of Y and Z










share|cite|improve this question




























    up vote
    2
    down vote

    favorite












    My Current Setup:



    Let's assume we have these 3 axes in 3d space.



    3D Axes
    Let's also assume that x = blue; y = red; green = z;



    To calculate a rotation on the x axis, i.e., from point A->E, we can calculate that by doing



    p1 = A
    p2 = Origin (Gray)
    p3 = E


    XAngleInRads Formula



    This would also work for A->C, however, to get the circular behavior we want, we need to do



    enter image description here



    All of this works great :)



    Now for,



    The Problem:



    So far, I have my X-Axis Rotation down perfectly. I am looking to rotate the Y and Z axis in such a manner that I NEVER rotate the INITIAL Z axis.



    Let's say I have 2 objects, object O and object P as noted on the picture.
    The goal is that as O translates and rotates, that P will only rotate to face O. However, we do NOT want the orientation of P to follow the orientation of O.



    Test Cases:



    Assume all rotations occur from Origin, so if we rotate O, then it moves. If we rotate P, it just turns.



    Let's start O at position A and P at position Origin. If we orient (rotate about Z) by 90 degrees, we do NOT want P to move.



    O Rotation (0, 0, 90) -- P Rotation (0, 0, 0)



    Let's now rotate O from position A->E.



    O Rotation (-90, 0, 0) -- P Rotation (-90, 0, 0)



    Now, let's go from E-> B. This is a rotation about the Z axis, but we DO want to move, because if we rotate the orientation of O, it is not the Y axis that we do NOT want to rotate.



    O Rotation (-90, 0, 90) -- P Rotation (-90, 0, 90)



    Now let's get back to point A by reversing the rotations.



    O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



    Now let's rotate A->B but also rotate O 90 degrees about Z. Because the rotation orientation is now back to the Z axis, we do NOT want P to rotate about the Z. So we have



    O Rotation (0, 90, 90) -- P Rotation (0, 90, 0).



    Let's go back to point A



    O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



    Now, let's go 45 degrees from A->E so we have



    O Rotation (45, 0, 0) -- P Rotation (45, 0, 0)



    Now rotate from currentPosition->B. This rotation requires that part of Z and part of Y are both part of orientation. It is half. So, we don't rotate both Y or Z by 90 degrees, we rotate each by 45 degrees, since it X rotation is in between Y and Z axis.



    O Rotation (45, 45, 45) -- P Rotation (45, 45, 45)



    Final Problem:



    So, I am in search of a formula to help me keep the "Initial Z Axis" locked, such that the orientation of P never changes at any rotation of X, Y, Z. You can see that I cannot just lock the Z axis for orientation, as at 90 and 270 degrees, the Z axis then becomes the Y axis, in terms of orientation. Any help in creating a formula as to rotate object O and P such that P rotates to follow O, however, if O rotates about orientation (spin), that P does not follow.



    Edit1:



    I have come up with the ratio of how much y (yRatio) and how much z (zRatio) according to the current xAngleInRadians. I'm just not sure what to do with these variables. I just know how much of Z and how much of Y we WANT to rotate. If O is at A, then we want 0(zero) Z rotation. If O is at E, then we want 0(zero) Y rotation. However, if O is 45 degrees between A and E, then we want 1/2 rotation for Y and Z.



    (ZRatio, YRatio) for picture sake.



    Ratio of Y and Z










    share|cite|improve this question


























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      My Current Setup:



      Let's assume we have these 3 axes in 3d space.



      3D Axes
      Let's also assume that x = blue; y = red; green = z;



      To calculate a rotation on the x axis, i.e., from point A->E, we can calculate that by doing



      p1 = A
      p2 = Origin (Gray)
      p3 = E


      XAngleInRads Formula



      This would also work for A->C, however, to get the circular behavior we want, we need to do



      enter image description here



      All of this works great :)



      Now for,



      The Problem:



      So far, I have my X-Axis Rotation down perfectly. I am looking to rotate the Y and Z axis in such a manner that I NEVER rotate the INITIAL Z axis.



      Let's say I have 2 objects, object O and object P as noted on the picture.
      The goal is that as O translates and rotates, that P will only rotate to face O. However, we do NOT want the orientation of P to follow the orientation of O.



      Test Cases:



      Assume all rotations occur from Origin, so if we rotate O, then it moves. If we rotate P, it just turns.



      Let's start O at position A and P at position Origin. If we orient (rotate about Z) by 90 degrees, we do NOT want P to move.



      O Rotation (0, 0, 90) -- P Rotation (0, 0, 0)



      Let's now rotate O from position A->E.



      O Rotation (-90, 0, 0) -- P Rotation (-90, 0, 0)



      Now, let's go from E-> B. This is a rotation about the Z axis, but we DO want to move, because if we rotate the orientation of O, it is not the Y axis that we do NOT want to rotate.



      O Rotation (-90, 0, 90) -- P Rotation (-90, 0, 90)



      Now let's get back to point A by reversing the rotations.



      O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



      Now let's rotate A->B but also rotate O 90 degrees about Z. Because the rotation orientation is now back to the Z axis, we do NOT want P to rotate about the Z. So we have



      O Rotation (0, 90, 90) -- P Rotation (0, 90, 0).



      Let's go back to point A



      O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



      Now, let's go 45 degrees from A->E so we have



      O Rotation (45, 0, 0) -- P Rotation (45, 0, 0)



      Now rotate from currentPosition->B. This rotation requires that part of Z and part of Y are both part of orientation. It is half. So, we don't rotate both Y or Z by 90 degrees, we rotate each by 45 degrees, since it X rotation is in between Y and Z axis.



      O Rotation (45, 45, 45) -- P Rotation (45, 45, 45)



      Final Problem:



      So, I am in search of a formula to help me keep the "Initial Z Axis" locked, such that the orientation of P never changes at any rotation of X, Y, Z. You can see that I cannot just lock the Z axis for orientation, as at 90 and 270 degrees, the Z axis then becomes the Y axis, in terms of orientation. Any help in creating a formula as to rotate object O and P such that P rotates to follow O, however, if O rotates about orientation (spin), that P does not follow.



      Edit1:



      I have come up with the ratio of how much y (yRatio) and how much z (zRatio) according to the current xAngleInRadians. I'm just not sure what to do with these variables. I just know how much of Z and how much of Y we WANT to rotate. If O is at A, then we want 0(zero) Z rotation. If O is at E, then we want 0(zero) Y rotation. However, if O is 45 degrees between A and E, then we want 1/2 rotation for Y and Z.



      (ZRatio, YRatio) for picture sake.



      Ratio of Y and Z










      share|cite|improve this question















      My Current Setup:



      Let's assume we have these 3 axes in 3d space.



      3D Axes
      Let's also assume that x = blue; y = red; green = z;



      To calculate a rotation on the x axis, i.e., from point A->E, we can calculate that by doing



      p1 = A
      p2 = Origin (Gray)
      p3 = E


      XAngleInRads Formula



      This would also work for A->C, however, to get the circular behavior we want, we need to do



      enter image description here



      All of this works great :)



      Now for,



      The Problem:



      So far, I have my X-Axis Rotation down perfectly. I am looking to rotate the Y and Z axis in such a manner that I NEVER rotate the INITIAL Z axis.



      Let's say I have 2 objects, object O and object P as noted on the picture.
      The goal is that as O translates and rotates, that P will only rotate to face O. However, we do NOT want the orientation of P to follow the orientation of O.



      Test Cases:



      Assume all rotations occur from Origin, so if we rotate O, then it moves. If we rotate P, it just turns.



      Let's start O at position A and P at position Origin. If we orient (rotate about Z) by 90 degrees, we do NOT want P to move.



      O Rotation (0, 0, 90) -- P Rotation (0, 0, 0)



      Let's now rotate O from position A->E.



      O Rotation (-90, 0, 0) -- P Rotation (-90, 0, 0)



      Now, let's go from E-> B. This is a rotation about the Z axis, but we DO want to move, because if we rotate the orientation of O, it is not the Y axis that we do NOT want to rotate.



      O Rotation (-90, 0, 90) -- P Rotation (-90, 0, 90)



      Now let's get back to point A by reversing the rotations.



      O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



      Now let's rotate A->B but also rotate O 90 degrees about Z. Because the rotation orientation is now back to the Z axis, we do NOT want P to rotate about the Z. So we have



      O Rotation (0, 90, 90) -- P Rotation (0, 90, 0).



      Let's go back to point A



      O Rotation (0, 0, 0) -- P Rotation (0, 0, 0)



      Now, let's go 45 degrees from A->E so we have



      O Rotation (45, 0, 0) -- P Rotation (45, 0, 0)



      Now rotate from currentPosition->B. This rotation requires that part of Z and part of Y are both part of orientation. It is half. So, we don't rotate both Y or Z by 90 degrees, we rotate each by 45 degrees, since it X rotation is in between Y and Z axis.



      O Rotation (45, 45, 45) -- P Rotation (45, 45, 45)



      Final Problem:



      So, I am in search of a formula to help me keep the "Initial Z Axis" locked, such that the orientation of P never changes at any rotation of X, Y, Z. You can see that I cannot just lock the Z axis for orientation, as at 90 and 270 degrees, the Z axis then becomes the Y axis, in terms of orientation. Any help in creating a formula as to rotate object O and P such that P rotates to follow O, however, if O rotates about orientation (spin), that P does not follow.



      Edit1:



      I have come up with the ratio of how much y (yRatio) and how much z (zRatio) according to the current xAngleInRadians. I'm just not sure what to do with these variables. I just know how much of Z and how much of Y we WANT to rotate. If O is at A, then we want 0(zero) Z rotation. If O is at E, then we want 0(zero) Y rotation. However, if O is 45 degrees between A and E, then we want 1/2 rotation for Y and Z.



      (ZRatio, YRatio) for picture sake.



      Ratio of Y and Z







      3d rotations angle






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Nov 21 at 16:17

























      asked Nov 21 at 15:58









      impression7vx

      1113




      1113



























          active

          oldest

          votes











          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',
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3007915%2fcalculate-3d-rotation-maintaining-orientation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          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%2f3007915%2fcalculate-3d-rotation-maintaining-orientation%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

          Probability when a professor distributes a quiz and homework assignment to a class of n students.

          Aardman Animations

          Are they similar matrix