I’m trying to make a rotation in 3d by quaternions, but i never deal with this before and the final result is really “shaky” and to this point i’m guessing how it works, any help please.
Thnks.
pitch=(obj.pitch*180)/(Math.PI);
yaw=(obj.yaw*180)/(Math.PI);
roll=(obj.roll*180)/(Math.PI);
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);
var quat1:Quaternion=new Quaternion;
quat1.fromMatrix(mtrx);
var quat2:Quaternion=new Quaternion;
quat2.fromMatrix(setV[a].transform);
quat2.slerp(quat2,quat1,0.1);
var mtrx2:Matrix3D=new Matrix3D();
quat1.toMatrix3D(mtrx2);
setV[a].transform=mtrx.clone();
trace("2 "+quat2);
trace("1 "+quat1);
traced:
2 {x:-0.19114455458549365 y:0.3862047890066849 z:0.8871870897898427 w:-0.1649506677498737}
1 {x:0.36467063426971436 y:0.7760035991668701 z:-0.48058098554611206 w:0.18405361473560333}