Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to rotate object in 3D space about its axis
QtWS25 Last Chance

How to rotate object in 3D space about its axis

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gde23
    wrote on 24 Dec 2020, 12:35 last edited by
    #2

    Lets say you have your object in its object coordinate system which is somehow arranged in space (rotated translated).
    Then to achieve a rotation of the object about its own local object coordinate system you need to first rotate the object (as long as it still in the origin xyz coordinate system) and then apply the rotation that positions it in space afterwards. So the order of the rotations / translations is what makes the difference.

    S 1 Reply Last reply 24 Dec 2020, 13:58
    0
    • G gde23
      24 Dec 2020, 12:35

      Lets say you have your object in its object coordinate system which is somehow arranged in space (rotated translated).
      Then to achieve a rotation of the object about its own local object coordinate system you need to first rotate the object (as long as it still in the origin xyz coordinate system) and then apply the rotation that positions it in space afterwards. So the order of the rotations / translations is what makes the difference.

      S Offline
      S Offline
      SpyerGame
      wrote on 24 Dec 2020, 13:58 last edited by
      #3

      @gde23 ur mean is after apply e.g. 'rotX = 25' then rotate the camera in x axis equal 25 degrees?
      Can u make example for this prb?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gde23
        wrote on 24 Dec 2020, 15:02 last edited by gde23
        #4

        I assume your object is made up of triangles or points or whatever and each of these points is defined in the local coordinate system of the object.

        Now as long as you do not translate/rotate your object, the local coordinate system will be the same as the global coordinate system. In this position now when you just rotate about x the object will pitch if you rotate about y it will roll and z yaw. Therefore if you first apply the picht/roll/yaw rotation matrix and afterwards the transformation to the global coordinate system it will be the same as if you first positioned the object in global coordinate system and afterwards rotate about those new rotated axes. (Which however would be more complicated math)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SpyerGame
          wrote on 24 Dec 2020, 17:40 last edited by
          #5

          Yes, exactly at the first time two coordinates are matching but must a way for any time and robust !

          K 1 Reply Last reply 24 Dec 2020, 18:09
          0
          • S SpyerGame
            24 Dec 2020, 17:40

            Yes, exactly at the first time two coordinates are matching but must a way for any time and robust !

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 24 Dec 2020, 18:09 last edited by
            #6

            The rotation property is a quaternion, which is rather hard to reason about directly. I'd suggest using a QTransform attached to your node instead.

            Read and abide by the Qt Code of Conduct

            S 1 Reply Last reply 24 Dec 2020, 18:28
            0
            • K kshegunov
              24 Dec 2020, 18:09

              The rotation property is a quaternion, which is rather hard to reason about directly. I'd suggest using a QTransform attached to your node instead.

              S Offline
              S Offline
              SpyerGame
              wrote on 24 Dec 2020, 18:28 last edited by SpyerGame
              #7

              @kshegunov Thanks, but I don't figure out completely!
              Cause Qtransform is in C++ and there is not in qml and how to use it

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gde23
                wrote on 24 Dec 2020, 18:38 last edited by
                #8

                It does not matter if you use quaternions or rotation/homgenious matrices for the rotations/translations as long as you keep the order.
                The advantage of rotation matrices however is, that you can multiply them to get a single matrix that does all the rotations at once.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SpyerGame
                  wrote on 24 Dec 2020, 19:11 last edited by SpyerGame
                  #9

                  Are these methods useful for my prb?
                  @gde23 in Model scope for rotation.x: property, I put this?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SpyerGame
                    wrote on 25 Dec 2020, 15:13 last edited by
                    #10

                    I Can't to solve this, yet!!

                    K 1 Reply Last reply 26 Dec 2020, 17:57
                    0
                    • S SpyerGame
                      25 Dec 2020, 15:13

                      I Can't to solve this, yet!!

                      K Offline
                      K Offline
                      kshegunov
                      Moderators
                      wrote on 26 Dec 2020, 17:57 last edited by kshegunov
                      #11

                      @gde23 said in How to rotate object in 3D space about its axis:

                      It does not matter if you use quaternions or rotation/homgenious matrices for the rotations/translations as long as you keep the order.

                      Not in principle, as it is just a matter of representation. Utility and convenience however can vary.

                      The advantage of rotation matrices however is, that you can multiply them to get a single matrix that does all the rotations at once.

                      Which is also true for quaternions. They have the same properties, being associative and obeying the distributive property, but do not form a commutative ring. But again, this is just the math, and not that helpful in this case.

                      @SpyerGame said in How to rotate object in 3D space about its axis:

                      Cause Qtransform is in C++ and there is not in qml and how to use it

                      I'm pretty sure there's a Transform QML element that's "related" to the QTransform class ... like this one ...

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SpyerGame
                        wrote on 26 Dec 2020, 19:05 last edited by SpyerGame
                        #12

                        Thanks, yes it is, but I think use fromAxesAndAngles but I don't know how to work each vector3d of axes. In other words if each of a,b & c in Qt.vector3d(a,b,c) !
                        I know that Qt.vector3d(1,0,0) is X axis and so on but I don't know what is it Qt.vector3d(.54,.1,0) ?
                        My desired rotation around X,Y & Z of object like this:
                        alt text

                        1 Reply Last reply
                        0

                        11/12

                        26 Dec 2020, 17:57

                        • Login

                        • Login or register to search.
                        11 out of 12
                        • First post
                          11/12
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved