向量间旋转矩阵高效计算

《Efficiently building a matrix to rotate one vector to another》, moller 1999

优点:

  • 无开方运算
  • 无三角计算

计算过程:
f\vec \bold{f} --> t\vec \bold{t}
v=f×t,u=v/v,c=ft,θ=arccos(c)\bold{\vec v = \vec f \times \vec t, \vec u = \vec v/\|\vec v\|, c = \vec f \cdot \vec t, \theta = arccos(c)}
R =

(ux2+(1ux2)cosθuxuy(1cosθ)uzsinθuxuz+uysinθuxuy(1cosθ)+uzsinθuy2+(1uy2)cosθuyuz(1cosθ)uxsinθuxuz(1cosθ)uysinθuyuz(1cosθ)+uxsinθuz2+(1ux2)cosθ)\small \boldsymbol{\begin{pmatrix} u_x^2+(1-u_x^2)cos\theta &u_xu_y(1-cos\theta)-u_zsin\theta &u_xu_z+u_ysin\theta\\ u_xu_y(1-cos\theta)+u_zsin\theta &u_y^2+(1-u_y^2)cos\theta &u_yu_z(1-cos\theta)-u_xsin\theta\\ u_xu_z(1-cos\theta)-u_ysin\theta &u_yu_z(1-cos\theta)+u_xsin\theta &u_z^2+(1-u_x^2)cos\theta\\ \end{pmatrix}}

h=1c1c2=1cvv\boldsymbol{h = \frac{1-c}{1-c^2}=\frac{1-c}{\vec v \cdot \vec v}}
R =

(c+hvx2hvxvyvzhvxvz+vyhvxvy+vzuc+hvy2hvyvzvxhvxvzvyhvyvz+vxc+hvz2)\small \boldsymbol{\begin{pmatrix} c+hv_x^2 &hv_xv_y-v_z &hv_xv_z+v_y\\ hv_xv_y+v_z &uc+hv_y^2 &hv_yv_z-v_x\\ hv_xv_z-v_y &hv_yv_z+v_x &c+hv_z^2\\ \end{pmatrix}}

HouseHolder Matrix:
H(u)=I2uuuutH(u)=I-\frac{2}{\vec u \cdot \vec u}\vec u \vec u^t