Yet another rotation problem guys

I need a hand with explaining why my Box does not rotate the way I want it to.



I use following code to rotate Box when key is pressed. I want the Box to be rotated instantly (y axis) in just one call to update. Here is the code that does this:



public void performAction(InputActionEvent evt) {

Matrix3f incr = new Matrix3f();
      Vector3f upAxis = new Vector3f(0,1,0);
      Matrix3f tempMa = new Matrix3f();
        incr.fromAxisAngle(upAxis, -FastMath.DEG_TO_RAD * 90);
        getVehicle().getLocalRotation().fromRotationMatrix(
                incr.mult(getVehicle().getLocalRotation().toRotationMatrix(tempMa),
                        null));
        getVehicle().getLocalRotation().normalize();
}



The problem is that when I turn the box couple of times left end right 90 deg. usually it rotates correctly. But it happens that after rotation box is not aligned properly along worlds x, y axis. When I rotate is 90 deg. left or right Box should always travel along worlds x or y axis but sometimes it doesn

if you want it to be completely perfect, you won't be able to amass rotations.  floating point errors will curse you everytime.

I know what you mean but I get 5 or 6 rotations perfect and then 7th is messed up badly. The second picture type badly I mean. So It cannot be FP precision error that changes so much in only one rotation can it?

Hmm, well I do notice you are calling normalize instead of normalizeLocal.  Might switch that.