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

How to rotate object in 3D space about its axis

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 3.7k Views 2 Watching
  • 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.
  • gde23G gde23

    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.

    SpyerGameS Offline
    SpyerGameS Offline
    SpyerGame
    wrote on 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
    • gde23G Offline
      gde23G Offline
      gde23
      wrote on 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
      • SpyerGameS Offline
        SpyerGameS Offline
        SpyerGame
        wrote on last edited by
        #5

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

        kshegunovK 1 Reply Last reply
        0
        • SpyerGameS SpyerGame

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

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on 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

          SpyerGameS 1 Reply Last reply
          0
          • kshegunovK kshegunov

            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.

            SpyerGameS Offline
            SpyerGameS Offline
            SpyerGame
            wrote on 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
            • gde23G Offline
              gde23G Offline
              gde23
              wrote on 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
              • SpyerGameS Offline
                SpyerGameS Offline
                SpyerGame
                wrote on 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
                • SpyerGameS Offline
                  SpyerGameS Offline
                  SpyerGame
                  wrote on last edited by
                  #10

                  I Can't to solve this, yet!!

                  kshegunovK 1 Reply Last reply
                  0
                  • SpyerGameS SpyerGame

                    I Can't to solve this, yet!!

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on 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
                    • SpyerGameS Offline
                      SpyerGameS Offline
                      SpyerGame
                      wrote on 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

                      • Login

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