向量间旋转矩阵高效计算

《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=f⃗⋅t⃗,θ=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+(1−ux2)cosθuxuy(1−cosθ)−uzsinθuxuz+uysinθuxuy(1−cosθ)+uzsinθuy2+(1−uy2)cosθuyuz(1−cosθ)−uxsinθuxuz(1−cosθ)−uysinθuyuz(1−cosθ)+uxsinθuz2+(1−ux2)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=1−c1−c2=1−cv⃗⋅v⃗\boldsymbol{h = \frac{1-c}{1-c^2}=\frac{1-c}{\vec v \cdot \vec v}}
R =

(c+hvx2hvxvy−vzhvxvz+vyhvxvy+vzuc+hvy2hvyvz−vxhvxvz−vyhvyvz+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)=I−2u⃗⋅u⃗u⃗u⃗tH(u)=I-\frac{2}{\vec u \cdot \vec u}\vec u \vec u^t