5 Replies Latest reply on Jun 21, 2007 12:31 PM by walfridson

    From axisangle to radians in 3d application.

    walfridson Level 1
      Hey
      Converting SW3D rotation values to a 3d application.
      RIght now I'm converting to radians from axisangle. But applied to object in 3d application (which is localrotation) the thing is rotated differently from the shockwave object.
      Any ideas how to convert the angles to localspace - if that is what I need to do :)
      Here's a picture. Not the best example shown but... When rotation get is more it shows more.
      http://walen.se/temp/rotate.jpg


      cheers
        • 1. Re: From axisangle to radians in 3d application.
          James Newton, ACP Level 3
          It looks to me as if you are dealing with different rotations in the top and bottom image. The axisAngle in the top image indicates which axis the cube has been rotated around from its rest position, and by how many degrees. The bottom image shows three rotations (H, P and B), not an axisAngle.

          Perhaps you would get the results you are expecting if you used the .transform.rotation property of the cube model. This returns a vector containing 3 angles: rotation around the x-axis, rotation around the y-axis and rotation around the z-axis. All these angles are already in degrees.

          Note that, to get to the desired orientation, the rotations are applied in order: first around the x-axis, then around the y-axis and lastly around the z-axis. Also, there are an infinite number of ways to arrive at the final rotation, so two transforms with different .rotation values may in fact have the same orientation.
          • 2. Re: From axisangle to radians in 3d application.
            walfridson Level 1
            Thanks
            Reason why I choose to go with the axislines is because its gives me much more "normal" values than a havokcontrolled object. -180 90 -180 etc...
            The heading works great. Problem is pitch and bank..

            This is how I convert to radians...
            myaxis = member("3dscene").model("body").transform.axisangle
            (((myaxis[1][2]*myaxis[2])+180)*(pi/180))

            Havokaxisangle gives me the exact same numbers.

            Tried using getworldtransform().rotation but that produced wicked rotation in 3d application.

            I'll make some anim gif to show what goes wrong...
            • 3. Re: From axisangle to radians in 3d application.
              James Newton, ACP Level 3
              There is a known quirk in transforms that can lead to the figures you associated with Havok.

              If you rotate a transform around its y-axis by setting the rotation of the transform, you can end up with strange-looking rotations such as vector(-180, 90, -180). Normally this occurs only when you set the rotation around the y-axis to a value between 90° and 270°. One solution is to set the rotation of the transform to vector(0, 0, 0), then use the rotate() method to apply the rotation for you.

              Instead of...

              vTransform.rotation = vector(0, 180, 0)

              ... try this:

              vTransform.rotation = vector(0, 0, 0)
              vTransform.rotate(vector(0, 180, 0))
              • 4. Re: From axisangle to radians in 3d application.
                walfridson Level 1
                Thanks James
                Problem is I'm not doing any rotation in the code really, its a havok model. So I only output the transform.

                uploaded some videos to show better what I'm having trouble with
                There are in xvid, if that is a problem let me know.

                http://walen.se/temp/axisanglefix.avi
                axisangle, +180 on all channels and *-1 on heading.

                http://walen.se/temp/rawaxis.avi
                axisangle, straight to radians.

                http://walen.se/temp/rawrotation.avi
                rotation, straight to radians.

                thanks for your time!
                • 5. Re: From axisangle to radians in 3d application.
                  walfridson Level 1
                  Alright, been able to recreate my problem in director by rotating a second object to my master's object axisangle.
                  So I get a difference in the rotation between the two.
                  Here's my director project, simple & clean. hopefully someone will take a look at it :)
                  http://walen.se/temp/showme_com.dir rightclick and save

                  cheers