I want to rotate by quaternion as left hand coordinate -


vector v = (x, y, z),

quaternion q = (u, w), u unreal vector.

cunjugate quaternion q* = (-u, w)

quaternion multiply

pg =
( p4,-p3, p2, p1)(q1)

( p3, p4,-p1, p2)(q2)

(-p2, p1, p4, p3)(q3)

(-p1,-p2,-p3, p4)(q4)

and real code

public quaternion multiply(quaternion quaternion)     {         quaternion tmpquaternion = new quaternion();          tmpquaternion.x = quaternion.x * w - quaternion.y * z + quaternion.z * y + quaternion.w * x;         tmpquaternion.y = quaternion.x * z + quaternion.y * w - quaternion.z * x + quaternion.w * y;         tmpquaternion.z = - quaternion.x * y + quaternion.y * x + quaternion.z * w + quaternion.w * z;         tmpquaternion.w = - quaternion.x * x - quaternion.y * y - quaternion.z * z + quaternion.w * w;          return tmpquaternion;     } 

q = (sin(θ/2)n, cos(θ/2)) (n rotation axis),

rotation operator rq(v) = qvq*(q unit quaternion),

public void rotate(common_math.matrix1x4 axis, int degree) {     double radian = math.toradians(degree);     common_math.quaternion rotatequaternion = new common_math.quaternion(axis.getx() * math.sin(radian * 0.5), axis.gety() * math.sin(radian * 0.5), axis.getz() * math.sin(radian * 0.5), math.cos(radian * 0.5));     rotatequaternion.normalize();      objectmatrix.setxvector(rotatequaternion.multiply(objectmatrix.xvector().multiply(rotatequaternion.reverse())));     objectmatrix.setyvector(rotatequaternion.multiply(objectmatrix.yvector().multiply(rotatequaternion.reverse())));     objectmatrix.setzvector(rotatequaternion.multiply(objectmatrix.zvector().multiply(rotatequaternion.reverse())));      objectmatrix.xvector().normalize();     objectmatrix.yvector().normalize();     objectmatrix.zvector().normalize(); } 

when try code got result , think result right hand coordinate, want left hand coordinate.

is there problem in code or should change there?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -