四元数基础公式总结

四元数基础公式总结

        • 四元数定义
          • 定义
          • 运算
          • 单位四元数

四元数定义

定义

一个四元数 q ^ \hat q q^定义如下:
q ^ = ( q ⃗ v , q w ) = i q x + j q y + k q z + q w = q ⃗ v + q w \hat q=(\vec q_v,q_w)=iq_x+jq_y+kq_z+q_w=\vec q_v+q_w q^=(q v,qw)=iqx+jqy+kqz+qw=q v+qw
q ⃗ v = i q x + j q y + k q z = ( q x , q y , q z ) \vec q_v=iq_x+jq_y+kq_z=(q_x,q_y,q_z) q v=iqx+jqy+kqz=(qx,qy,qz)
i 2 = j 2 = k 2 = − 1 , j k = − k j = i , k i = − i k = j , i j = − j i = k i^2=j^2=k^2=-1,jk=-kj=i,ki=-ik=j,ij=-ji=k i2=j2=k2=1,jk=kj=i,ki=ik=j,ij=ji=k
变量 q w q_w qw称为四元数实部, q ⃗ v \vec q_v q v称为四元数虚部, i , j , k i,j,k i,j,k称为虚部单位。

运算

对于四元数而言,一般的向量运算都适用于四元数。

  • 乘法运算: q ^ r ^ = ( i q x + j q y + k q z + q w ) ( i r x + j r y + k r z + r w ) + i ( q y r z − q z r y + r w q x + q w r x ) + j ( q z r x − q x r z + r w q y + q w r y ) + k ( q x r y − q y r x + r w q z + q w r y ) + q w r w − q x r x − q y r y − q z r z = ( q ⃗ v × r ⃗ v + r w q ⃗ v + q w r ⃗ v , q w r w − q ⃗ v ⋅ r ⃗ v ) \begin{aligned}\hat q\hat r&=(iq_x+jq_y+kq_z+q_w)(ir_x+jr_y+kr_z+r_w)\\&+i(q_yr_z-q_zr_y+r_wq_x+q_wr_x)\\&+j(q_zr_x-q_xr_z+r_wq_y+q_wr_y)\\&+k(q_xr_y-q_yr_x+r_wq_z+q_wr_y)\\&+q_wr_w-q_xr_x-q_yr_y-q_zr_z\\&=(\vec q_v\times \vec r_v+r_w\vec q_v+q_w\vec r_v,q_wr_w-\vec q_v\cdot\vec r_v)\end{aligned} q^r^=(iqx+jqy+kqz+qw)(irx+jry+krz+rw)+i(qyrzqzry+rwqx+qwrx)+j(qzrxqxrz+rwqy+qwry)+k(qxryqyrx+rwqz+qwry)+qwrwqxrxqyryqzrz=(q v×r v+rwq v+qwr v,qwrwq vr v)
  • 加法运算: q ^ + r ^ = ( q ⃗ v , q w ) + ( r ⃗ v , r w ) = ( q ⃗ v + r ⃗ v , q w + r w ) \hat q+\hat r=(\vec q_v,q_w)+(\vec r_v,r_w)=(\vec q_v+\vec r_v,q_w+r_w) q^+r^=(q v,qw)+(r v,rw)=(q v+r v,qw+rw)
  • 共轭运算: q ^ ∗ = ( q ⃗ v , q w ) ∗ = ( − q ⃗ v , q w ) \hat q^\ast=(\vec q_v,q_w)^\ast=(-\vec q_v,q_w) q^=(q v,qw)=(q v,qw)
  • 第二范数: n ( q ^ ) = q ^ q ^ ∗ = q ^ ∗ q ^ = q ⃗ v ⋅ q ⃗ v + q w 2 = q x 2 + q y 2 + q z 2 + q w 2 n(\hat q)=\sqrt{\hat q\hat q^\ast}=\sqrt{\hat q^\ast\hat q}=\sqrt{\vec q_v\cdot\vec q_v+q_w^2}=\sqrt{q_x^2+q_y^2+q_z^2+q_w^2} n(q^)=q^q^ =q^q^ =q vq v+qw2 =qx2+qy2+qz2+qw2
  • Identity: i ^ = ( 0 ⃗ , 1 ) \hat i=(\vec 0,1) i^=(0 ,1)
  • 求逆: q ^ − 1 = 1 n ( q ^ ) 2 q ^ ∗ \hat q^{-1}=\frac {1}{n(\hat q)^2}\hat q^\ast q^1=n(q^)21q^
  • 数乘: q ^ s = s q ^ = ( 0 ⃗ , s ) ( q ⃗ v , q w ) \hat qs=s\hat q=(\vec 0,s)(\vec q_v,q_w) q^s=sq^=(0 ,s)(q v,qw)
  • 共轭法则: ( q ^ ∗ ) ∗ = q ^ (\hat q^\ast)^\ast=\hat q (q^)=q^ ( q ^ + r ^ ) ∗ = q ^ ∗ + r ^ ∗ (\hat q+\hat r)^\ast=\hat q^\ast+\hat r^\ast (q^+r^)=q^+r^ ( q ^ r ^ ) ∗ = r ^ ∗ q ^ ∗ (\hat{q}\hat r)^\ast=\hat r^\ast\hat q^\ast (q^r^)=r^q^
  • 范数法则: n ( q ^ ∗ ) = n ( q ^ ) n(\hat q^\ast)=n(\hat q) n(q^)=n(q^) n ( q ^ r ^ ) = n ( q ^ ) n ( r ^ ) n(\hat{q}\hat r)=n(\hat q)n(\hat r) n(q^r^)=n(q^)n(r^)
  • 乘法法则:
    • 分配律: p ^ ( s q ^ + t r ^ ) = s p ^ q ^ + t p ^ r ^ \hat p(s\hat q+t\hat r)=s\hat p\hat q+t\hat p\hat r p^(sq^+tr^)=sp^q^+tp^r^ ( s p ^ + t q ^ ) r ^ = s p ^ r ^ + t q ^ r ^ (s\hat p+t\hat q)\hat r=s\hat p\hat r+t\hat q\hat r (sp^+tq^)r^=sp^r^+tq^r^
    • 结合律: p ^ ( q ^ r ^ ) = ( p ^ q ^ ) r ^ \hat p(\hat q\hat r)=(\hat p\hat q)\hat r p^(q^r^)=(p^q^)r^
单位四元数

n ( q ^ ) = 1 n(\hat q)=1 n(q^)=1的四元数称为单位四元数,可写作:
q ^ = ( sin ⁡ ϕ u ⃗ q , cos ⁡ ϕ ) = sin ⁡ ϕ u ⃗ q + cos ⁡ ϕ = e ϕ u ⃗ q \hat q=(\sin \phi\vec u_q,\cos \phi)=\sin\phi\vec u_q+\cos \phi=e^{\phi\vec u_q} q^=(sinϕu q,cosϕ)=sinϕu q+cosϕ=eϕu q

  • 对数: log ⁡ ( q ^ ) = log ⁡ ( e ϕ u ⃗ q ) = ϕ u ⃗ q \log(\hat q)=\log(e^{\phi\vec u_q})=\phi\vec u_q log(q^)=log(eϕu q)=ϕu q
  • 幂: q ^ t = ( sin ⁡ ϕ u ⃗ q + cos ⁡ ϕ ) t = e ϕ t u ⃗ q = sin ⁡ ( ϕ t ) u ⃗ q + cos ⁡ ( ϕ t ) \hat q^t=(\sin\phi\vec u_q+\cos\phi)^t=e^{\phi t\vec u_q}=\sin(\phi t)\vec u_q+\cos(\phi t) q^t=(sinϕu q+cosϕ)t=eϕtu q=sin(ϕt)u q+cos(ϕt)

你可能感兴趣的:(计算机图形学基础)