Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    rotateObject() changes the coordinate system

    Advanced
    3d-maths rotation
    4
    20
    1164
    Loading More Posts
    • 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.
    • Tratax
      Tratax F @spikey last edited by Tratax

      @spikey I might be misinterpreting but are you wanting one object to rotate and move around another object like how planets rotate around the sun?

      1 Reply Last reply Reply Quote 0
      • Mincus
        Mincus F last edited by

        3D rotations are done with transformation matrices. Multiplying by matrix being non-commutative (a * b has a different result than b * a) is just an intrinsic property of the math used.

        So the short answer is, you can't. You always have to perform the rotations in the same order.

        1 Reply Last reply Reply Quote 0
        • spikey
          spikey F last edited by

          @Tratax you can absolutely look at it this way. What you are saying is the end target. Just use cubes instead of spheres. So not only the coordinates rotate, but also the cube itself. Therefore the coordinate sytem of both rotations need to have the same orientation. And the example shows that they change.

          1 Reply Last reply Reply Quote 0
          • spikey
            spikey F last edited by

            @Mincus you are right. I rechecked. I was wrong. They do not have to be oriented in the same way afterwards. Can you tell me if the rotation matrices are depending on the orientation of the coordinate sytem. Maybe i got matrices for thewrong coord system.

            1 Reply Last reply Reply Quote 0
            • spikey
              spikey F last edited by spikey

              I use this rotation matrices:
              0fdb2d21-50a6-437e-8516-0a6f0b277a8b-image.png
              I will provide more details, tonight.

              1 Reply Last reply Reply Quote 1
              • spikey
                spikey F last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • Tratax
                  Tratax F last edited by

                  I have two examples of this in my Robo 3D game.

                  Basically i took and scaled up the sin/cos demo code and then used the angle variable to control the direction and position of x/y movement, I then set the cameras position behind it and then rotated it around the player object, rotation of the player object was then adjusted so the player would rotate with the camera

                  I was thinking about putting an orb spinning around the players position but I'm waiting for the next patch as I suspect we'll have some new 3D functions

                  Eitherway, feel free to check the demo out!
                  SW-8184-9059-9116

                  1 Reply Last reply Reply Quote 0
                  • spikey
                    spikey F last edited by

                    @Tratax thank you for your answer, I will check the example. And I came to a similar conclusion according to your orb-idea (would love it): currently its super hard to spin an object in sync with an object in a certain distance, only using the functions we have in 3D. But I thought if I only get the math right, I could achieve it.

                    So, I end up that all code I check, FUZE or mine, is correct: e.g.

                    • rotateObject() --> axis: OK, rotation: right-handed: OK
                    • the matrices above --> right-handed: OK
                    • my own matrice multiplcation functions --> checked with online calculator examples: OK
                      ..so the only possibilities left is: I still have the math wrong or it is not possible yet. So, I recheck the math, part by part.
                    1 Reply Last reply Reply Quote 0
                    • spikey
                      spikey F last edited by spikey

                      SW-4464-9632-0709
                      My head is rotating. But my customObjects are just swirling. Maybe some one can spot the problem.

                      Tratax 1 Reply Last reply Reply Quote 0
                      • spikey
                        spikey F last edited by

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • Tratax
                          Tratax F @spikey last edited by

                          @spikey Awesome work! Mind sharing up the code? Curious to see how you've done this

                          spikey 1 Reply Last reply Reply Quote 0
                          • spikey
                            spikey F @Tratax last edited by

                            @Tratax Yes, its shared, you should have a friend request hanging ;-)
                            Actually, its not usefull yet, because I can not find out how to handle the self-rotation axis of the red object. In my cube game, I did this with ifs: if rotx, roty, rotz = 270/180/or what ever then switch rot axis of rotateObject() to {0,1,0} or what ever. But then the complexity blew off the roof when I joined 3D objects. So, I started this test program above to get the maths right first.

                            1 Reply Last reply Reply Quote 0
                            • spikey
                              spikey F last edited by spikey

                              Isolation of the problem for the blue object (I updated the shared code as well):
                              rotation_axis.jpg


                              I would like to use the same axis for rotation in C as in A.

                              I try now to find out how to rotate my inital axis manually so it fits the axis used by rotateObject(). the other way would be to switch the rotation axis in the parameter of rotateObject().

                              I still have no clue, so if you know how to do it, I would be happy for any help.
                              Probably its just a small operation, but just cant see it. Thanks.

                              1 Reply Last reply Reply Quote 0
                              • spikey
                                spikey F last edited by

                                @Tratax thanks for letting me have a look. This was smart to put the cam behind the object, because the objects-axis are always oriented like one is sitting in it. Though I can not use that principle, when having multiple objects. I give it another go. By the way, I like your well-thought-out splash screen and design from pong, as well. Nice style.

                                1 Reply Last reply Reply Quote 1
                                • spikey
                                  spikey F last edited by

                                  code updated:
                                  I could find a bug in the matrix-multiplication and found a way to revert the rotation on the blue rectangular cuboid. So, if I press j.left its left side is moving down (rotating around the old z, even after rotating it first around the y-axis.
                                  But if I do only a 45° rotation the y-axis it swirls around its length axis. (?) Anyone knows somebody working with robotics?

                                  1 Reply Last reply Reply Quote 0
                                  • spikey
                                    spikey F last edited by

                                    I almost gave up. So, I would like to share that, to shorten your path, if you decide to do some 3D. I found out that there is a local coordinate system and global coordinate system if you program a 3D scene. (If you knew it, don't tell me now ;-))
                                    If you want to rotate multiple objects you have to track the rotation changes for every object to be able to call the rotateObject() for each object with the appropriate axis.

                                    It would be very helpful to have a rotateObjectGlobal() function that rotates all objects according to the global coordinate system.

                                    Dave 1 Reply Last reply Reply Quote 2
                                    • Dave
                                      Dave Fuze Team @spikey last edited by

                                      @spikey This is a truly impressive series of posts, we commend you massively for this, showing your working out - it's awesome to see.

                                      You're going to love (or maybe hate!) a few new functions coming in the next patch ;)

                                      1 Reply Last reply Reply Quote 0
                                      • spikey
                                        spikey F last edited by

                                        Thank you :) I am glad if this is interesting for others as well. Hey, I can imagine what you mean, haha, but the patch I am gonna love any way.

                                        1 Reply Last reply Reply Quote 0
                                        • spikey
                                          spikey F last edited by spikey

                                          To be able to re-use the code I put it into a rotateCustomObject(customObjectHandle, axis, angle) function. And shared it (SW-4464-9632-0709), if you are interested.
                                          Maybe I will have to update it, because the movement was not tested yet, and I think also of being able to set a rotation origin :---)
                                          If you find bugs, thanks for the feedback - if you have a suggested fix, go ahead, thanks.

                                          rotateCustomObjectCode.jpg

                                          rotateCustomObject_screen.jpg

                                          1 Reply Last reply Reply Quote 1
                                          • First post
                                            Last post