ロドリゲスの回転公式
#回転行列 #回転 #Transform #行列
回転軸となる3次元ベクトルと角度から位置ベクトルを射影するやつ
https://en.wikipedia.org/wiki/Axis–angle_representation
https://en.wikipedia.org/wiki/Rodrigues'_rotation_formula
https://w3e.kanazawa-it.ac.jp/math/physics/category/physical_math/linear_algebra/henkan-tex.cgi?target=/math/physics/category/physical_math/linear_algebra/rodrigues_rotation_formula.html
公式
射影される位置ベクトルを$ \bm r・回転軸となる単位ベクトルを$ \bm u・回転する角度$ \thetaとしたとき、
$ \bm r' = \bm r \cos \theta + (\bm u \times \bm r) \sin \theta + \bm u (\bm u \cdot \bm r) (1 - \cos \theta)
行列
3次元回転行列を出す
いわゆる Matrix3.fromAxisAngle
回転軸となる単位ベクトル$ \bm u・回転する角度$ \thetaを用いて、
$ \bf R = \begin{bmatrix} u_x^2 (1 - \cos \theta) + \cos \theta & u_x u_y (1 - \cos \theta) - u_z \sin \theta & u_x u_z (1 - \cos \theta) + u_y \sin \theta \\ u_x u_y (1 - \cos \theta) + u_z \sin \theta & u_y^2 (1 - \cos \theta) + \cos \theta & u_y u_z (1 - \cos \theta) - u_x \sin \theta \\ u_x u_z (1 - \cos \theta) - u_y \sin \theta & u_y u_z (1 - \cos \theta) + u_x \sin \theta & u_z^2 (1 - \cos \theta) + \cos \theta \end{bmatrix}
分解
$ \bf U = \begin{bmatrix} 0 & -u_z & u_y \\ u_z & 0 & -u_x \\ -u_y & u_x & 0 \end{bmatrix}とおき、
$ \bf R = \bf I + \sin \theta \ \bf U + (1 - \cos \theta) \ \bf U^2