2D rotation mistake

Ahem… I have a normalized 2d vector. I want to rotate a quad on the gui node around the Z axis

So I did this:

Quaternion roll180 = new Quaternion(); 
roll180.lookAt(look, Vector3f.UNIT_Z);
node.setLocalRotation( roll180 );

However, the end result is that the node is not drawn regardless of the value of the “look” vector… any suggestion is welcome. Thanks!

Just a random shot - is scale updated to match GUI node scale?

No, I didn’t scale it… however with this code, it worked:

roll180.fromAngleAxis( currentRotation , new Vector3f(0,0,1) );

Then try to use asymmetrically scaled box instead of quad to see around what axis you are really rotating your node with your code - chances are that your quad is just orthogonal to camera and so you don’t see it.

I’ve noticed something wrong with the resulting Quaternion. A “good” result is something like:

(0.0, 0.0, A, B)

But instead I get:

(A, B, B, A)

I could try to zero the first two components, but something tells me that’s not the right way… :stuck_out_tongue:

OK, apparently is orthogonal… solved with atan2 calculation.

new Quaternion().fromAngles(0, 0, yourAngleInRads);

1 Like