3D Axis Rotation & New Value Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How to extract Euler angles from a a point in a plane?rotate a roll pitch and yaw using a rotation matrixDisable one angle of rotationRotation about an arbitrary axisRotating a set of anges (pitch/yaw/roll) by another set of angles (pitch/yaw/roll)3D calculate new location of point after rotation around originEuler angle to direction vector which is right?How to calculate relative pitch, roll and yaw given absolutesHow can a 3D rotational transformation between two cartesian coordinate systems be performed?3D Coordinate Rotation Using Roll-Pitch-Yaw

preposition before coffee

Is there hard evidence that the grant peer review system performs significantly better than random?

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

What makes a man succeed?

How to compare two different files line by line in unix?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

Why is it faster to reheat something than it is to cook it?

What does 丫 mean? 丫是什么意思?

Random body shuffle every night—can we still function?

How were pictures turned from film to a big picture in a picture frame before digital scanning?

Maximum summed subsequences with non-adjacent items

What is the meaning of 'breadth' in breadth first search?

What do you call the main part of a joke?

What is best way to wire a ceiling receptacle in this situation?

Project Euler #1 in C++

Google .dev domain strangely redirects to https

How do I find out the mythology and history of my Fortress?

Why are vacuum tubes still used in amateur radios?

A term for a woman complaining about things/begging in a cute/childish way

What does this say in Elvish?

The test team as an enemy of development? And how can this be avoided?

How often does castling occur in grandmaster games?

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

How could we fake a moon landing now?



3D Axis Rotation & New Value



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How to extract Euler angles from a a point in a plane?rotate a roll pitch and yaw using a rotation matrixDisable one angle of rotationRotation about an arbitrary axisRotating a set of anges (pitch/yaw/roll) by another set of angles (pitch/yaw/roll)3D calculate new location of point after rotation around originEuler angle to direction vector which is right?How to calculate relative pitch, roll and yaw given absolutesHow can a 3D rotational transformation between two cartesian coordinate systems be performed?3D Coordinate Rotation Using Roll-Pitch-Yaw










0












$begingroup$


In a 3D space I want to rotate the origin,just rotating. Let, rotational angles be roll, pitch, yaw.



As it is here.



Now let's say I have a vector 0 i+0 j -9.8 k.



What will be the value the vector given vector for any roll ($alpha$), pitch ($beta$), yaw($gamma$) ?










share|cite|improve this question









$endgroup$











  • $begingroup$
    Have you tried visualizing the vector $langle 0,0,-9.8 rangle$? Are you familiar with viewing matrices as linear transformations? If so, what matrix would correspond to a rotation about any of the axis in $mathbb R^3$?
    $endgroup$
    – Brian
    Apr 2 at 2:12










  • $begingroup$
    No. Can you help me out ?
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 9:35










  • $begingroup$
    I may have found a solution here : Stack-overflow link
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 10:17






  • 1




    $begingroup$
    Maifee, if the above answer suffices, considering post it as an answer to your question so that this post might be removed from the unanswered tab.
    $endgroup$
    – Brian
    Apr 2 at 13:58










  • $begingroup$
    @Brian , I have posted the answer.. I had no idea is it okay to copy-paste answer or not..
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 14:31















0












$begingroup$


In a 3D space I want to rotate the origin,just rotating. Let, rotational angles be roll, pitch, yaw.



As it is here.



Now let's say I have a vector 0 i+0 j -9.8 k.



What will be the value the vector given vector for any roll ($alpha$), pitch ($beta$), yaw($gamma$) ?










share|cite|improve this question









$endgroup$











  • $begingroup$
    Have you tried visualizing the vector $langle 0,0,-9.8 rangle$? Are you familiar with viewing matrices as linear transformations? If so, what matrix would correspond to a rotation about any of the axis in $mathbb R^3$?
    $endgroup$
    – Brian
    Apr 2 at 2:12










  • $begingroup$
    No. Can you help me out ?
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 9:35










  • $begingroup$
    I may have found a solution here : Stack-overflow link
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 10:17






  • 1




    $begingroup$
    Maifee, if the above answer suffices, considering post it as an answer to your question so that this post might be removed from the unanswered tab.
    $endgroup$
    – Brian
    Apr 2 at 13:58










  • $begingroup$
    @Brian , I have posted the answer.. I had no idea is it okay to copy-paste answer or not..
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 14:31













0












0








0


0



$begingroup$


In a 3D space I want to rotate the origin,just rotating. Let, rotational angles be roll, pitch, yaw.



As it is here.



Now let's say I have a vector 0 i+0 j -9.8 k.



What will be the value the vector given vector for any roll ($alpha$), pitch ($beta$), yaw($gamma$) ?










share|cite|improve this question









$endgroup$




In a 3D space I want to rotate the origin,just rotating. Let, rotational angles be roll, pitch, yaw.



As it is here.



Now let's say I have a vector 0 i+0 j -9.8 k.



What will be the value the vector given vector for any roll ($alpha$), pitch ($beta$), yaw($gamma$) ?







geometry 3d






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Apr 2 at 2:05









Maifee Ul AsadMaifee Ul Asad

1177




1177











  • $begingroup$
    Have you tried visualizing the vector $langle 0,0,-9.8 rangle$? Are you familiar with viewing matrices as linear transformations? If so, what matrix would correspond to a rotation about any of the axis in $mathbb R^3$?
    $endgroup$
    – Brian
    Apr 2 at 2:12










  • $begingroup$
    No. Can you help me out ?
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 9:35










  • $begingroup$
    I may have found a solution here : Stack-overflow link
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 10:17






  • 1




    $begingroup$
    Maifee, if the above answer suffices, considering post it as an answer to your question so that this post might be removed from the unanswered tab.
    $endgroup$
    – Brian
    Apr 2 at 13:58










  • $begingroup$
    @Brian , I have posted the answer.. I had no idea is it okay to copy-paste answer or not..
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 14:31
















  • $begingroup$
    Have you tried visualizing the vector $langle 0,0,-9.8 rangle$? Are you familiar with viewing matrices as linear transformations? If so, what matrix would correspond to a rotation about any of the axis in $mathbb R^3$?
    $endgroup$
    – Brian
    Apr 2 at 2:12










  • $begingroup$
    No. Can you help me out ?
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 9:35










  • $begingroup$
    I may have found a solution here : Stack-overflow link
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 10:17






  • 1




    $begingroup$
    Maifee, if the above answer suffices, considering post it as an answer to your question so that this post might be removed from the unanswered tab.
    $endgroup$
    – Brian
    Apr 2 at 13:58










  • $begingroup$
    @Brian , I have posted the answer.. I had no idea is it okay to copy-paste answer or not..
    $endgroup$
    – Maifee Ul Asad
    Apr 2 at 14:31















$begingroup$
Have you tried visualizing the vector $langle 0,0,-9.8 rangle$? Are you familiar with viewing matrices as linear transformations? If so, what matrix would correspond to a rotation about any of the axis in $mathbb R^3$?
$endgroup$
– Brian
Apr 2 at 2:12




$begingroup$
Have you tried visualizing the vector $langle 0,0,-9.8 rangle$? Are you familiar with viewing matrices as linear transformations? If so, what matrix would correspond to a rotation about any of the axis in $mathbb R^3$?
$endgroup$
– Brian
Apr 2 at 2:12












$begingroup$
No. Can you help me out ?
$endgroup$
– Maifee Ul Asad
Apr 2 at 9:35




$begingroup$
No. Can you help me out ?
$endgroup$
– Maifee Ul Asad
Apr 2 at 9:35












$begingroup$
I may have found a solution here : Stack-overflow link
$endgroup$
– Maifee Ul Asad
Apr 2 at 10:17




$begingroup$
I may have found a solution here : Stack-overflow link
$endgroup$
– Maifee Ul Asad
Apr 2 at 10:17




1




1




$begingroup$
Maifee, if the above answer suffices, considering post it as an answer to your question so that this post might be removed from the unanswered tab.
$endgroup$
– Brian
Apr 2 at 13:58




$begingroup$
Maifee, if the above answer suffices, considering post it as an answer to your question so that this post might be removed from the unanswered tab.
$endgroup$
– Brian
Apr 2 at 13:58












$begingroup$
@Brian , I have posted the answer.. I had no idea is it okay to copy-paste answer or not..
$endgroup$
– Maifee Ul Asad
Apr 2 at 14:31




$begingroup$
@Brian , I have posted the answer.. I had no idea is it okay to copy-paste answer or not..
$endgroup$
– Maifee Ul Asad
Apr 2 at 14:31










1 Answer
1






active

oldest

votes


















0












$begingroup$

This answer is directly copied from here (Stack-Overflow).




If you want to rotate a vector you should construct what is known as a rotation matrix.



Rotation in 2D



Say you want to rotate a vector or a point by θ, then trigonometry states that the new coordinates are




x' = x cos θ − y sin θ
y' = x sin θ + y cos θ


To demo this, let's take the cardinal axes of X and Y; when we rotate the X-axis 90° counter-clockwise, we should end up with the X-axis transformed into Y-axis. X-axis as a unit-vector is




unit vector along X axis = <1, 0>
x' = 1 cos 90 − 0 sin 90 = 0
y' = 1 sin 90 + 0 cos 90 = 1
New coordinates of the vector = <x', y'> = <0, 1> => Y-axis.


When you understand this, creating a matrix to do this becomes simple. A matrix is just a mathematical tool to perform this in a comfortable, generalized way so that various transformations like rotation, scale and translation (moving) can be combined and performed in a single step, using one common method. From linear algebra, to rotate a point or vector in 2D, the matrix to be built is




|cos θ −sin θ| |x| = |x cos θ − y sin θ| = |x'|
|sin θ cos θ| |y| |x sin θ + y cos θ| |y'|


Rotation in 3D



That works in 2D, while in 3D we need to take in to account the third axis. Rotating a vector around the origin (a point) in 2D simply means rotating it around the Z-axis (a line) in 3D; since we're rotating around Z-axis its coordinates should kept constant i.e. 0° (the rotation happens on the XY plane in 3D). In 3D rotating around the Z-axis would be




|cos θ −sin θ 0| |x| |x cos θ − y sin θ| |x'|
|sin θ cos θ 0| |y| = |x sin θ + y cos θ| = |y'|
| 0 0 1| |z| | z | |z'|


around the Y-axis would be




| cos θ 0 sin θ| |x| | x cos θ + z sin θ| |x'|
| 0 1 0| |y| = | y | = |y'|
|−sin θ 0 cos θ| |z| |−x sin θ + z cos θ| |z'|


around the X-axis would be




|1 0 0| |x| | x | |x'|
|0 cos θ −sin θ| |y| = |y cos θ − z sin θ| = |y'|
|0 sin θ cos θ| |z| |y sin θ + z cos θ| |z'|


Note that the axis around which rotation is done has no sin or cos elements in the matrix. I hope this makes the rotation case clear.



Composition



The aforementioned matrices rotate an object as if the object is at a distance r = √(x² + y²) from the origin; lookup polar coordinates to know why. This rotation will be with respect to the world space origin. Usually we need to rotate an object around its own frame/pivot and not around the world's. Since not all objects are at the world origin, rotating using these matrices will not give the desired result of rotating around the object's own frame. Hence you need to learn about translation too. You'd first translate (move) the object to world origin (so that the object's origin would align with the world's, thereby making r = 0), perform the rotation with one (or more) of these matrices and then translate it back again to its previous location. The order in which the transforms are applied matters.



I urge you to read about linear and affine transformations and their composition to perform multiple transformations in one shot, before playing with transformations in code. Without understanding the basic maths behind it, debugging transformations would be a nightmare. I found this lecture video to be a very good resource. Another resource is this tutorial on transformations that aims to be intuitive and illustrates the ideas with animation.



Note: This method of performing rotations follows the Euler angle rotation system, which is simpler to teach and to grasp. This works perfectly fine for 2D and for simple 3D cases; but when rotation needs to be performed around all three axes at the same time then Euler angles are not sufficient for this due to an inherent deficiency in this system which manifests itself as Gimbal lock. People resort to Quaternions in such situations, which is more advanced than this but doesn't suffer from Gimbal locks when used correctly.







share|cite|improve this answer











$endgroup$













    Your Answer








    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3171374%2f3d-axis-rotation-new-value%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












    $begingroup$

    This answer is directly copied from here (Stack-Overflow).




    If you want to rotate a vector you should construct what is known as a rotation matrix.



    Rotation in 2D



    Say you want to rotate a vector or a point by θ, then trigonometry states that the new coordinates are




    x' = x cos θ − y sin θ
    y' = x sin θ + y cos θ


    To demo this, let's take the cardinal axes of X and Y; when we rotate the X-axis 90° counter-clockwise, we should end up with the X-axis transformed into Y-axis. X-axis as a unit-vector is




    unit vector along X axis = <1, 0>
    x' = 1 cos 90 − 0 sin 90 = 0
    y' = 1 sin 90 + 0 cos 90 = 1
    New coordinates of the vector = <x', y'> = <0, 1> => Y-axis.


    When you understand this, creating a matrix to do this becomes simple. A matrix is just a mathematical tool to perform this in a comfortable, generalized way so that various transformations like rotation, scale and translation (moving) can be combined and performed in a single step, using one common method. From linear algebra, to rotate a point or vector in 2D, the matrix to be built is




    |cos θ −sin θ| |x| = |x cos θ − y sin θ| = |x'|
    |sin θ cos θ| |y| |x sin θ + y cos θ| |y'|


    Rotation in 3D



    That works in 2D, while in 3D we need to take in to account the third axis. Rotating a vector around the origin (a point) in 2D simply means rotating it around the Z-axis (a line) in 3D; since we're rotating around Z-axis its coordinates should kept constant i.e. 0° (the rotation happens on the XY plane in 3D). In 3D rotating around the Z-axis would be




    |cos θ −sin θ 0| |x| |x cos θ − y sin θ| |x'|
    |sin θ cos θ 0| |y| = |x sin θ + y cos θ| = |y'|
    | 0 0 1| |z| | z | |z'|


    around the Y-axis would be




    | cos θ 0 sin θ| |x| | x cos θ + z sin θ| |x'|
    | 0 1 0| |y| = | y | = |y'|
    |−sin θ 0 cos θ| |z| |−x sin θ + z cos θ| |z'|


    around the X-axis would be




    |1 0 0| |x| | x | |x'|
    |0 cos θ −sin θ| |y| = |y cos θ − z sin θ| = |y'|
    |0 sin θ cos θ| |z| |y sin θ + z cos θ| |z'|


    Note that the axis around which rotation is done has no sin or cos elements in the matrix. I hope this makes the rotation case clear.



    Composition



    The aforementioned matrices rotate an object as if the object is at a distance r = √(x² + y²) from the origin; lookup polar coordinates to know why. This rotation will be with respect to the world space origin. Usually we need to rotate an object around its own frame/pivot and not around the world's. Since not all objects are at the world origin, rotating using these matrices will not give the desired result of rotating around the object's own frame. Hence you need to learn about translation too. You'd first translate (move) the object to world origin (so that the object's origin would align with the world's, thereby making r = 0), perform the rotation with one (or more) of these matrices and then translate it back again to its previous location. The order in which the transforms are applied matters.



    I urge you to read about linear and affine transformations and their composition to perform multiple transformations in one shot, before playing with transformations in code. Without understanding the basic maths behind it, debugging transformations would be a nightmare. I found this lecture video to be a very good resource. Another resource is this tutorial on transformations that aims to be intuitive and illustrates the ideas with animation.



    Note: This method of performing rotations follows the Euler angle rotation system, which is simpler to teach and to grasp. This works perfectly fine for 2D and for simple 3D cases; but when rotation needs to be performed around all three axes at the same time then Euler angles are not sufficient for this due to an inherent deficiency in this system which manifests itself as Gimbal lock. People resort to Quaternions in such situations, which is more advanced than this but doesn't suffer from Gimbal locks when used correctly.







    share|cite|improve this answer











    $endgroup$

















      0












      $begingroup$

      This answer is directly copied from here (Stack-Overflow).




      If you want to rotate a vector you should construct what is known as a rotation matrix.



      Rotation in 2D



      Say you want to rotate a vector or a point by θ, then trigonometry states that the new coordinates are




      x' = x cos θ − y sin θ
      y' = x sin θ + y cos θ


      To demo this, let's take the cardinal axes of X and Y; when we rotate the X-axis 90° counter-clockwise, we should end up with the X-axis transformed into Y-axis. X-axis as a unit-vector is




      unit vector along X axis = <1, 0>
      x' = 1 cos 90 − 0 sin 90 = 0
      y' = 1 sin 90 + 0 cos 90 = 1
      New coordinates of the vector = <x', y'> = <0, 1> => Y-axis.


      When you understand this, creating a matrix to do this becomes simple. A matrix is just a mathematical tool to perform this in a comfortable, generalized way so that various transformations like rotation, scale and translation (moving) can be combined and performed in a single step, using one common method. From linear algebra, to rotate a point or vector in 2D, the matrix to be built is




      |cos θ −sin θ| |x| = |x cos θ − y sin θ| = |x'|
      |sin θ cos θ| |y| |x sin θ + y cos θ| |y'|


      Rotation in 3D



      That works in 2D, while in 3D we need to take in to account the third axis. Rotating a vector around the origin (a point) in 2D simply means rotating it around the Z-axis (a line) in 3D; since we're rotating around Z-axis its coordinates should kept constant i.e. 0° (the rotation happens on the XY plane in 3D). In 3D rotating around the Z-axis would be




      |cos θ −sin θ 0| |x| |x cos θ − y sin θ| |x'|
      |sin θ cos θ 0| |y| = |x sin θ + y cos θ| = |y'|
      | 0 0 1| |z| | z | |z'|


      around the Y-axis would be




      | cos θ 0 sin θ| |x| | x cos θ + z sin θ| |x'|
      | 0 1 0| |y| = | y | = |y'|
      |−sin θ 0 cos θ| |z| |−x sin θ + z cos θ| |z'|


      around the X-axis would be




      |1 0 0| |x| | x | |x'|
      |0 cos θ −sin θ| |y| = |y cos θ − z sin θ| = |y'|
      |0 sin θ cos θ| |z| |y sin θ + z cos θ| |z'|


      Note that the axis around which rotation is done has no sin or cos elements in the matrix. I hope this makes the rotation case clear.



      Composition



      The aforementioned matrices rotate an object as if the object is at a distance r = √(x² + y²) from the origin; lookup polar coordinates to know why. This rotation will be with respect to the world space origin. Usually we need to rotate an object around its own frame/pivot and not around the world's. Since not all objects are at the world origin, rotating using these matrices will not give the desired result of rotating around the object's own frame. Hence you need to learn about translation too. You'd first translate (move) the object to world origin (so that the object's origin would align with the world's, thereby making r = 0), perform the rotation with one (or more) of these matrices and then translate it back again to its previous location. The order in which the transforms are applied matters.



      I urge you to read about linear and affine transformations and their composition to perform multiple transformations in one shot, before playing with transformations in code. Without understanding the basic maths behind it, debugging transformations would be a nightmare. I found this lecture video to be a very good resource. Another resource is this tutorial on transformations that aims to be intuitive and illustrates the ideas with animation.



      Note: This method of performing rotations follows the Euler angle rotation system, which is simpler to teach and to grasp. This works perfectly fine for 2D and for simple 3D cases; but when rotation needs to be performed around all three axes at the same time then Euler angles are not sufficient for this due to an inherent deficiency in this system which manifests itself as Gimbal lock. People resort to Quaternions in such situations, which is more advanced than this but doesn't suffer from Gimbal locks when used correctly.







      share|cite|improve this answer











      $endgroup$















        0












        0








        0





        $begingroup$

        This answer is directly copied from here (Stack-Overflow).




        If you want to rotate a vector you should construct what is known as a rotation matrix.



        Rotation in 2D



        Say you want to rotate a vector or a point by θ, then trigonometry states that the new coordinates are




        x' = x cos θ − y sin θ
        y' = x sin θ + y cos θ


        To demo this, let's take the cardinal axes of X and Y; when we rotate the X-axis 90° counter-clockwise, we should end up with the X-axis transformed into Y-axis. X-axis as a unit-vector is




        unit vector along X axis = <1, 0>
        x' = 1 cos 90 − 0 sin 90 = 0
        y' = 1 sin 90 + 0 cos 90 = 1
        New coordinates of the vector = <x', y'> = <0, 1> => Y-axis.


        When you understand this, creating a matrix to do this becomes simple. A matrix is just a mathematical tool to perform this in a comfortable, generalized way so that various transformations like rotation, scale and translation (moving) can be combined and performed in a single step, using one common method. From linear algebra, to rotate a point or vector in 2D, the matrix to be built is




        |cos θ −sin θ| |x| = |x cos θ − y sin θ| = |x'|
        |sin θ cos θ| |y| |x sin θ + y cos θ| |y'|


        Rotation in 3D



        That works in 2D, while in 3D we need to take in to account the third axis. Rotating a vector around the origin (a point) in 2D simply means rotating it around the Z-axis (a line) in 3D; since we're rotating around Z-axis its coordinates should kept constant i.e. 0° (the rotation happens on the XY plane in 3D). In 3D rotating around the Z-axis would be




        |cos θ −sin θ 0| |x| |x cos θ − y sin θ| |x'|
        |sin θ cos θ 0| |y| = |x sin θ + y cos θ| = |y'|
        | 0 0 1| |z| | z | |z'|


        around the Y-axis would be




        | cos θ 0 sin θ| |x| | x cos θ + z sin θ| |x'|
        | 0 1 0| |y| = | y | = |y'|
        |−sin θ 0 cos θ| |z| |−x sin θ + z cos θ| |z'|


        around the X-axis would be




        |1 0 0| |x| | x | |x'|
        |0 cos θ −sin θ| |y| = |y cos θ − z sin θ| = |y'|
        |0 sin θ cos θ| |z| |y sin θ + z cos θ| |z'|


        Note that the axis around which rotation is done has no sin or cos elements in the matrix. I hope this makes the rotation case clear.



        Composition



        The aforementioned matrices rotate an object as if the object is at a distance r = √(x² + y²) from the origin; lookup polar coordinates to know why. This rotation will be with respect to the world space origin. Usually we need to rotate an object around its own frame/pivot and not around the world's. Since not all objects are at the world origin, rotating using these matrices will not give the desired result of rotating around the object's own frame. Hence you need to learn about translation too. You'd first translate (move) the object to world origin (so that the object's origin would align with the world's, thereby making r = 0), perform the rotation with one (or more) of these matrices and then translate it back again to its previous location. The order in which the transforms are applied matters.



        I urge you to read about linear and affine transformations and their composition to perform multiple transformations in one shot, before playing with transformations in code. Without understanding the basic maths behind it, debugging transformations would be a nightmare. I found this lecture video to be a very good resource. Another resource is this tutorial on transformations that aims to be intuitive and illustrates the ideas with animation.



        Note: This method of performing rotations follows the Euler angle rotation system, which is simpler to teach and to grasp. This works perfectly fine for 2D and for simple 3D cases; but when rotation needs to be performed around all three axes at the same time then Euler angles are not sufficient for this due to an inherent deficiency in this system which manifests itself as Gimbal lock. People resort to Quaternions in such situations, which is more advanced than this but doesn't suffer from Gimbal locks when used correctly.







        share|cite|improve this answer











        $endgroup$



        This answer is directly copied from here (Stack-Overflow).




        If you want to rotate a vector you should construct what is known as a rotation matrix.



        Rotation in 2D



        Say you want to rotate a vector or a point by θ, then trigonometry states that the new coordinates are




        x' = x cos θ − y sin θ
        y' = x sin θ + y cos θ


        To demo this, let's take the cardinal axes of X and Y; when we rotate the X-axis 90° counter-clockwise, we should end up with the X-axis transformed into Y-axis. X-axis as a unit-vector is




        unit vector along X axis = <1, 0>
        x' = 1 cos 90 − 0 sin 90 = 0
        y' = 1 sin 90 + 0 cos 90 = 1
        New coordinates of the vector = <x', y'> = <0, 1> => Y-axis.


        When you understand this, creating a matrix to do this becomes simple. A matrix is just a mathematical tool to perform this in a comfortable, generalized way so that various transformations like rotation, scale and translation (moving) can be combined and performed in a single step, using one common method. From linear algebra, to rotate a point or vector in 2D, the matrix to be built is




        |cos θ −sin θ| |x| = |x cos θ − y sin θ| = |x'|
        |sin θ cos θ| |y| |x sin θ + y cos θ| |y'|


        Rotation in 3D



        That works in 2D, while in 3D we need to take in to account the third axis. Rotating a vector around the origin (a point) in 2D simply means rotating it around the Z-axis (a line) in 3D; since we're rotating around Z-axis its coordinates should kept constant i.e. 0° (the rotation happens on the XY plane in 3D). In 3D rotating around the Z-axis would be




        |cos θ −sin θ 0| |x| |x cos θ − y sin θ| |x'|
        |sin θ cos θ 0| |y| = |x sin θ + y cos θ| = |y'|
        | 0 0 1| |z| | z | |z'|


        around the Y-axis would be




        | cos θ 0 sin θ| |x| | x cos θ + z sin θ| |x'|
        | 0 1 0| |y| = | y | = |y'|
        |−sin θ 0 cos θ| |z| |−x sin θ + z cos θ| |z'|


        around the X-axis would be




        |1 0 0| |x| | x | |x'|
        |0 cos θ −sin θ| |y| = |y cos θ − z sin θ| = |y'|
        |0 sin θ cos θ| |z| |y sin θ + z cos θ| |z'|


        Note that the axis around which rotation is done has no sin or cos elements in the matrix. I hope this makes the rotation case clear.



        Composition



        The aforementioned matrices rotate an object as if the object is at a distance r = √(x² + y²) from the origin; lookup polar coordinates to know why. This rotation will be with respect to the world space origin. Usually we need to rotate an object around its own frame/pivot and not around the world's. Since not all objects are at the world origin, rotating using these matrices will not give the desired result of rotating around the object's own frame. Hence you need to learn about translation too. You'd first translate (move) the object to world origin (so that the object's origin would align with the world's, thereby making r = 0), perform the rotation with one (or more) of these matrices and then translate it back again to its previous location. The order in which the transforms are applied matters.



        I urge you to read about linear and affine transformations and their composition to perform multiple transformations in one shot, before playing with transformations in code. Without understanding the basic maths behind it, debugging transformations would be a nightmare. I found this lecture video to be a very good resource. Another resource is this tutorial on transformations that aims to be intuitive and illustrates the ideas with animation.



        Note: This method of performing rotations follows the Euler angle rotation system, which is simpler to teach and to grasp. This works perfectly fine for 2D and for simple 3D cases; but when rotation needs to be performed around all three axes at the same time then Euler angles are not sufficient for this due to an inherent deficiency in this system which manifests itself as Gimbal lock. People resort to Quaternions in such situations, which is more advanced than this but doesn't suffer from Gimbal locks when used correctly.








        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Apr 2 at 15:35









        Brian

        1,499416




        1,499416










        answered Apr 2 at 14:30









        Maifee Ul AsadMaifee Ul Asad

        1177




        1177



























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3171374%2f3d-axis-rotation-new-value%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

            Triangular numbers and gcdProving sum of a set is $0 pmod n$ if $n$ is odd, or $fracn2 pmod n$ if $n$ is even?Is greatest common divisor of two numbers really their smallest linear combination?GCD, LCM RelationshipProve a set of nonnegative integers with greatest common divisor 1 and closed under addition has all but finite many nonnegative integers.all pairs of a and b in an equation containing gcdTriangular Numbers Modulo $k$ - Hit All Values?Understanding the Existence and Uniqueness of the GCDGCD and LCM with logical symbolsThe greatest common divisor of two positive integers less than 100 is equal to 3. Their least common multiple is twelve times one of the integers.Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Then $c = gcd(a,b)$Which is the gcd of 2 numbers which are multiplied and the result is 600000?

            Ingelân Ynhâld Etymology | Geografy | Skiednis | Polityk en bestjoer | Ekonomy | Demografy | Kultuer | Klimaat | Sjoch ek | Keppelings om utens | Boarnen, noaten en referinsjes Navigaasjemenuwww.gov.ukOffisjele webside fan it regear fan it Feriene KeninkrykOffisjele webside fan it Britske FerkearsburoNederlânsktalige ynformaasje fan it Britske FerkearsburoOffisjele webside fan English Heritage, de organisaasje dy't him ynset foar it behâld fan it Ingelske kultuergoedYnwennertallen fan alle Britske stêden út 'e folkstelling fan 2011Notes en References, op dizze sideEngland

            Հադիս Բովանդակություն Անվանում և նշանակություն | Դասակարգում | Աղբյուրներ | Նավարկման ցանկ