Ok, I've been banging my head against this for awhile now, and just can't seem to figure out what I am doing wrong.
If I rotate about a single axis, (1,0,0) for example, everything is as it should be. However...
I am rotating a box about the axis (1,1,1). To do this, I create a quaternion from the axis (1,1,1) and the current angle (increasing over time).
One the screen, the box is rotating, but it is also being skewed (i.e. stretched). The stretching gets worse as it approaches a 180 degree turn.
I've track the problem to my Quaternion object's fromAxisAngle method. So, I am using javax.vecmath.Quat4f as reference.
Now, here's where your help comes in :)
Results from the test:
Rotating about a single axis (my version is correct here). With an angle of 1. (radians)
My result: [x=0.0 y=0.0 z=0.47942555 w=0.87758255]
vecmath result: (0.0, 0.0, 0.47942555, 0.87758255)
However, the results with an axis of (1,1,1) and an angle of 1.
My result: [x=0.47942555 y=0.47942555 z=0.47942555 w=0.87758255]
vecmath result: (0.27679646, 0.27679646, 0.27679646, 0.87758255)
As you can see the x,y,z are off substantially, but w is correct.
The code I am using for the conversion is pretty standard:
float halfAngle = 0.5f * angle;
float sin = (float) Math.sin(halfAngle);
w = (float) Math.cos(halfAngle);
x = sin * axis.x;
y = sin * axis.y;
z = sin * axis.z;
Any clues as to what I am doing wrong?