Saturday, July 30, 2016

Explaining Quaternion Rotation Matrix

With a quaternion q=q0+q1i+q2j+q3k, the rotation matrix is:
[q20+q21q22q232q1q22q0q32q1q3+2q0q22q1q2+2q0q3q20+q22q21q232q2q32q0q12q1q32q0q22q2q3+2q0q1q20+q23q21q22]


A quaternion is determined by two factors: normalized rotation axis (ax,ay,az) and rotation angle θ. q=cos(θ/2)+(axi+ayj+azk)sin(θ/2) and q1=cos(θ/2)(axi+ayj+azk)sin(θ/2). This means that ||q||=1.

The rotation matrix in term of (ax,ay,az) and θ is:
[1+(a2x1)(1cos(θ))azsin(θ)+axay(1cos(θ))aysin(θ)+axaz(1cos(θ))azsin(θ)+axay(1cos(θ))1+(a2y1)(1cos(θ))axsin(θ)+ayaz(1cos(θ))aysin(θ)+axaz(1cos(θ))axsin(θ)+ayaz(1cos(θ))1+(a2z1)(1cos(θ))]


From the expression of quaternion, we have
cos(θ)=cos2(θ/2)sin2(θ/2)=q20(q21+q22+q23)

1cos(θ)=1cos2(θ/2)+sin2(θ/2)=2sin2(θ/2)

(ax,ay,az)=(q1,q2,q3)/sin(θ/2)


Based on these equations, we can derive the quaternion rotation matrix. For example,
1+(a2x1)(1cos(θ))=cos(θ)+a2x(1cos(θ))=q20(q21+q22+q23)+2q21=q20+q21q22q23

azsin(θ)+axay(1cos(θ))=q3sin(θ/2)sin(θ)+q1q2sin2(θ/2)2sin2(θ/2)=2q1q22q0q3

No comments:

Post a Comment