I agree, there should be a toAxisAngle function. Instead I am doing this process manually:
float ax, ay, az;
float quatScale = (float)Math.sqrt(quat.getX()*quat.getX() + quat.getY()*quat.getY() + quat.getZ()*quat.getZ());
float quatAngle;
if (quatScale == 0) { //no rotation
ax = 1; ay = 0; az = 0;
quatAngle = 0;
}else{
ax = quat.getX() / quatScale;
ay = quat.getY() / quatScale;
az = quat.getZ() / quatScale;
quatAngle = 2 * (float)Math.acos(quat.getW());
}
The axis is stored in ax, ay and az and the angle in quatAngle.
It would be really nice if someone could optimise this code and put it into a function for the Quaternion class. Anyone?