回転

一覧

3次元の回転行列 オイラー角 クォータニオン

各軸周りでの回転 matRotateXYZ

matRotateXYZ
X軸、Y軸またはZ軸を中心に軸周りで回転
X軸で回転 Y軸で回転 Z軸で回転
入力
point LREAL[3] 回転前の座標
axis USINT 回転軸 0=X 1=Y 2=Z
angle LREAL 回転角度
出力
out LREAL[3] 移動後の座標

【 例 】
point(X=1,Y=1,Z=1)の位置をX軸周りで30度回転する例です
入力
point [1,1,1]
axis 0
angle 30.0
出力
out [1.00, 0.37, 1.37]

【 計算式 】
X軸周り \[ out= \begin{bmatrix} 1 & 0 & 0 \\ 0 & cos{\theta} & -sin{\theta} \\ 0 & sin{\theta} & cos{\theta} \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \] Y軸周り \[ out= \begin{bmatrix} cos{\theta} & 0 & sin{\theta} \\ 0 & 1 & 0 \\ -sin{\theta} & 0 & cos{\theta} \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \] Z軸周り \[ out= \begin{bmatrix} cos{\theta} & -sin{\theta} & 0 \\ sin{\theta} & cos{\theta} & 0 \\ 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \]


オイラー角での回転

EulerToMatrix, matRotate3D
オイラー角を回転行列に変換(EulerToMatrix)して回転(matRotate3D)
# この動画は計算の手順をイメージするもので実際の計算は最初の位置から最後の位置を直接算出します

入力
point LREAL[3] 回転前の座標
mat LREAL[3,3] 回転行列
出力
out LREAL[3] 移動後の座標

【 例 】
point(X=1,Y=1,Z=1)をオイラー角X=30度、Y=30度、Z=0度で、XYZの順番で回転する例です
オイラー角を回転行列に変換してpointを回転しています

入力
EulerAngles [30,30,0]
order XYZ
Point [1.0, 1.0, 1.0]
mat
出力
out [1.37, 0.68, 0.82]

【 計算式 】
\[ out= \begin{bmatrix} m00 & m01 & m02 \\ m10 & m11 & m12 \\ m20 & m21 & m22 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \]


クォータニオン qtRotate

qtRotate
クォータニオンで回転
入力
vector keisan\sVectol3d 回転軸の方向ベクトル
point LREAL[3] 回転前の座標
angle LREAL 回転角度
出力
out LREAL[3] 移動後の座標

【 例 】
入力
vector [1.0, 1.0, 1.0]
point [1.0, 0.3, 0.1]
angle 150.0
出力
out [-0.05, 0.87, 0.58]

【 計算式 】
元のベクトル \[ Q1= \begin{bmatrix} q_w \\ q_x \\ q_y \\ q_z \\ \end{bmatrix} = \begin{bmatrix} 0 \\ x \\ y \\ z \\ \end{bmatrix} = \begin{bmatrix} 0 \\ point.x \\ point.y \\ point.z \\ \end{bmatrix} \] 回転軸(単位ベクトル) \[ T= \begin{bmatrix} vector.x \\ vector.y \\ vector.z \\ \end{bmatrix} \] 回転を表すクォータニオン \[ R= \begin{bmatrix} q_w \\ q_x \\ q_y \\ q_z \\ \end{bmatrix} = \begin{bmatrix} cos\frac{\theta}{2} \\ sin\frac{\theta}{2} T_x \\ sin\frac{\theta}{2} T_y \\ sin\frac{\theta}{2} T_z \\ \end{bmatrix} \] 回転の計算
\[ out = R \times Q1 \times \bar{R} \]