Quaternions from matrix3D appendRotation pitch,roll,yaw

Software: Away3D 4.x

zkr13, Newbie
Posted: 10 April 2015 04:22 PM   Total Posts: 12

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} 
   

zkr13, Newbie
Posted: 13 April 2015 10:05 PM   Total Posts: 12   [ # 1 ]

When i try to create a Quaternion form an existing matrix 3d it returns an empty Quaternion. BUG?

var quaT:Quaternion=new Quaternion;
quaT.fromMatrix(Obj.transform);
trace("quat" +quaT);

tracedquat{x:0 y:0 z:0 w:1} 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X