I'm trying to append the pitch,roll and yaw of an object to a matrix3d, then get que quaternions and slerp the rotation... but the result it's really shaky, its the first time i deal with quaternions and i'm new in 3d programing, to this point i'm guessing the correct use of quaternions (to avoid gimbal lock) is there a way to not "append" just "assign" the new rotation values?
pitch=(obj.pitch);
yaw=(obj.yaw);
roll=(obj.roll);
mtrx:Matrix3D=new Matrix3D();
mtrx=setV[a].transform.clone();
mtrx.appendRotation(pitch,Vector3D.Y_AXIS);
mtrx.appendRotation(roll,Vector3D.X_AXIS);
mtrx.appendRotation(yaw,Vector3D.Z_AXIS);
quat1:Quaternion=new Quaternion;
quat1.fromMatrix(mtrx);
quat2:Quaternion=new Quaternion;
quat2.fromMatrix(setV[a].transform);
quat2.slerp(quat2,quat1,0.1);
mtrx2:Matrix3D=new Matrix3D();
quat1.toMatrix3D(mtrx2);
setV[a].transform=mtrx.clone();
Check this class, I made it for IMU Brick, so if you have a similar device, it may work for you. I was obtaining the values from javascript, but that may be different in your case. You may also need to tweak the relX, relY... etc (observe how, for example, I had to change the quaternionArray[0] to be negative, etc.).
Then, in some other class (my main, in this case) I simply call:
Also note that the js error catching makes no sense in my case cos I was sure that it will never fail. Of course if it may fall for you, you will have to handle it (my code would actually throw some error in that case).