I am having a hard time getting a matrix to turn locally. I have tried a lot of combinations of quat and matrix multiplications, but am having no luck. Can anyone help?
The global turning is easy. But I am trying to make the matrix turn on its own axes:
The global turning is easy. But I am trying to make the matrix turn on its own axes:
Method Turn(r:TVec3,glob=0) If glob quaternion=quaternion.times(r.toquat()) rotation=quaternion.toeuler() Else Local q:TQuat q=r.toquat() q=q.times(mat.inverse().rotation()) 'qmat=qmat.times(mat) 'q=qmat.rotation() ' Local q:TQuat=r.toquat() 'q=qmat.rotation()'.Times(q) ' 'qmat=qmat.times(mat) quaternion=quaternion.times(q) rotation=quaternion.toeuler() 'rotation=rotation.plus(r) 'quaternion=rotation.toquat() EndIf UpdateMatrix() EndMethod