Rotation representation
星期四, 31. 八月 2017 03:28下午
Outline
Roll,pitch,yaw
roll: 翻滚 沿着x轴旋转
pitch: 倾斜,坠落 沿着y轴旋转
yaw: 偏航 沿着z轴旋转
Quaternions
* Definition:
- i2 = j2 = k2 =-1
- ij = k, jk = i, ki = j, ji = -k, kj = -i, ik = -j
- q = s + x i + y j + z k
* Rules:
- q1 q2 ≠ q2 q1
- (q1 q2) q3 = q1 (q2 q3)
- (q1 + q2) q3 = q1 q3 + q2 q3
- q1 (q2 + q3) = q1 q2 + q1 q3
- α (q1 + q2) = α q1 + α q2 (α is scalar)
- (αq1) q2 = α (q1q2) = q1 (αq2) (α is scalar)
- Norm: |q|2= s2 + x2 + y2 + z2 (|q|2 != q*q= s2 - x2 - y2 -z2+2s(xi+yj+zk))
- Conjugate: q* = s-xi-yj-zk
- Inverse: q-1=q*/|q|2
- unit quaternion: |q| = 1 –> q-1= q*
* Quaternions and Rotations
Rotations are represented by unit quaternions.
|q|2= s2 + x2 + y2 + z2 = 1Let (unit) rotation axis be [ux, uy, uz], and angle θ
Corresponding quaternion is q = cos(θ/2) + sin(θ/2)uxi+sin(θ/2)uyj+sin(θ/2)uzk
Composition of rotations q1 and q2: q = q2 q1 ≠ q1 q2(not commute)Quaternion-xyzw:
x = ux * sin(θ / 2)
y = uy * sin(θ / 2)
z = uz * sin(θ / 2)
w = cos(θ / 2)Let v be a (3-dim) vector and let q be a unit quaternion:
the corresponding rotation transforms vector v to q v q-1 ,where v = 0+xi+yj+zk = [i,j,k] * [x;y;z]
q v q-1 = [i,j,k] *(R [x;y;z]) (s化为0了)For q = a+bi+cj+dk, R can be expressed as below…
Quaternions q and -q give the same rotation
* Geometric Explanation of Quaternions
- A quaternion is a point on the 4-D unit sphere.
- Interpolating rotations corresponds to curves on the 4-D sphere
(两点+圆心总能作出一个圆,由该圆为大圆可以得到一个球,该大圆的法线方向为旋转轴,两点的弧对应的角度为绕该轴的旋转角,这些是最开始定义中,q = cos(θ/2) + sin(θ/2)uxi+sin(θ/2)uyj+sin(θ/2)uzk 里面的ux uy uz 和θ)
* Applications: Spherical Linear intERPolation(SLERP)
- Situation:Interpolate along the great circle on the 4-D unit sphere(changing from one rotation state to another)
- Solution: pick the shortest(SLERP)
cos(θ)=q1q2 =s1s2+x1x2+y1y2+z1z2
u: from 0–>1
qm = sm + xm i + ym j + zm k, m =1,2
The above formula does not produce a unit quaternion and must be normalized, replace q by q / |q| - Realization:
- Improvement:
To be more smooth:combined with spline.
From http://run.usc.edu/cs520-s12/quaternions/quaternions-cs520.pdf