Scale affect rotation? Any workarounds??

Is there any workaround for the test code below. I would like to get the same rotation values out as I put in:


import javax.media.j3d.*;
import javax.vecmath.*;

public class RotationTest {
      
      public RotationTest() {
      }
      
      public static void main(String[] args) {
            Transform3D t= new Transform3D();
            Matrix3d rotationScale = new Matrix3d();
            AxisAngle4d      rotation      = new AxisAngle4d(0, -1, 0, Math.PI/2);
            System.out.println(rotation);
            t.set(new Vector3d(10,0,10));
            t.setRotation(rotation);
            t.setScale(0.5d);
            t.getRotationScale(rotationScale);
            rotation.set(rotationScale);
            System.out.println(rotation);
      }
}

Test result:
(0.0, -1.0, 0.0, 1.5707963267948966)
(0.0, -1.0, 0.0, 2.0344438552856445)

You could try to add “rotationScale.setScale(1)” to remove the scale from rotationScale.

[quote]You could try to add “rotationScale.setScale(1)” to remove the scale from rotationScale.
[/quote]
I cannot just revert the setScale. If I try to do a setScale(1d); the rotation still comes out the same. If I try to do a setScale(2d); same bad result.

The rotation is not corrupted inside the matrix4d, since my model displays correctly translation, scale and rotation in my 3D world. So somehow I should be able to retreive the rotation, it must be there, otherwise it would not be drawn correctly.

Is the corrrect Matrix4d inside the retained node only, and the normal matrix4d is corrupted but displays correct since it is not even used for displaying, the retained one is?

Workaround anyone?


import javax.media.j3d.*; 
import javax.vecmath.*; 
 
public class RotationTest { 
  
 public RotationTest() { 
 } 
  
 public static void main(String[] args) { 
  Transform3D t= new Transform3D(); 
  Matrix3d rotationScale = new Matrix3d(); 
  AxisAngle4d rotation = new AxisAngle4d(0, -1, 0, Math.PI/2); 
  System.out.println(rotation); 
  t.set(new Vector3d(10,0,10)); 
  t.setRotation(rotation); 
  t.setScale(0.5d); 
  t.getRotationScale(rotationScale); 
  rotationScale.setScale(1);
  rotation.set(rotationScale); 
  System.out.println(rotation); 
 } 
} 

Test result:
(0.0, -1.0, 0.0, 1.5707963267948966)
(0.0, -1.0, 0.0, 1.5707963705062866)

Output same as input. Notice the “rotationScale.setScale(1)” :wink:

I have had some problem with Netbeans not always compiling when pressing F6. I tried your fix yesterday but got same result, I now think it was not compiled properly cause it does work now.

Thank you.

Should this fix not be build into AxisAngle4d.set(Matrix3d)?