“三维旋转的表示”的版本间的差异
第5行: | 第5行: | ||
R(\phi,X) = | R(\phi,X) = | ||
\begin{pmatrix} 1&0&0 \\ 0&\cos(\phi) & -\sin(\phi) \\ 0& \sin(\phi) & \cos(\phi) | \begin{pmatrix} 1&0&0 \\ 0&\cos(\phi) & -\sin(\phi) \\ 0& \sin(\phi) & \cos(\phi) | ||
\end{pmatrix} | \end{pmatrix}, | ||
R(\phi,Y) = | R(\phi,Y) = | ||
\begin{pmatrix} \cos(\phi)&0&\sin(\phi) \\ 0&1&0 \\ -\sin(\phi)&0&\cos(\phi) | \begin{pmatrix} \cos(\phi)&0&\sin(\phi) \\ 0&1&0 \\ -\sin(\phi)&0&\cos(\phi) | ||
\end{pmatrix} | \end{pmatrix}, | ||
R(\phi,Z) = | R(\phi,Z) = | ||
\begin{pmatrix} \cos(\phi) & -\sin(\phi) & 0 \\ \sin(\phi) & \cos(\phi) & 0 \\ 0 & 0 & 1 | \begin{pmatrix} \cos(\phi) & -\sin(\phi) & 0 \\ \sin(\phi) & \cos(\phi) & 0 \\ 0 & 0 & 1 | ||
第20行: | 第14行: | ||
$$ | $$ | ||
于是连续两次绕世界轴旋转的旋转$$(Z(\phi)-X(\theta))$$的旋转矩阵为$$R(\theta,X)R(\phi,Z)$$ | |||
在ROOT中,TRotation即为旋转矩阵,使用方法如下 | 在ROOT中,TRotation即为旋转矩阵,使用方法如下 | ||
第39行: | 第35行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===通过欧拉角表示三维旋转=== | ===通过欧拉角表示三维旋转=== | ||
第46行: | 第43行: | ||
R_{ZX'Z''}(\psi,\theta,\phi) = R_{ZXZ}(\phi,\theta,\psi) = R(\psi,Z)R(\theta,X)R(\phi,Z)'' | R_{ZX'Z''}(\psi,\theta,\phi) = R_{ZXZ}(\phi,\theta,\psi) = R(\psi,Z)R(\theta,X)R(\phi,Z)'' | ||
$$ | $$ | ||
在ROOT中构建欧拉角旋转的旋转矩阵 | |||
<syntaxhighlight lang="cpp" line="1"> | |||
//////////////////////////////////////////////////////////////////////////////// | |||
/// Rotate using the x-convention. | |||
TRotation & TRotation::RotateXEulerAngles(Double_t phi, | |||
Double_t theta, | |||
Double_t psi) { | |||
TRotation euler; | |||
euler.SetXEulerAngles(phi,theta,psi); | |||
return Transform(euler); | |||
} | |||
//////////////////////////////////////////////////////////////////////////////// | |||
/// Rotate using the x-convention (Landau and Lifshitz, Goldstein, &c) by | |||
/// doing the explicit rotations. This is slightly less efficient than | |||
/// directly applying the rotation, but makes the code much clearer. My | |||
/// presumption is that this code is not going to be a speed bottle neck. | |||
TRotation & TRotation::SetXEulerAngles(Double_t phi, | |||
Double_t theta, | |||
Double_t psi) { | |||
SetToIdentity(); | |||
RotateZ(phi); | |||
RotateX(theta); | |||
RotateZ(psi); | |||
return *this; | |||
} | |||
///得到一个(Z(phi)-X(theta)-Z(psi))的外旋欧拉角旋转(extrinsic rotations)的旋转矩阵,即(Z(psi)-X'(theta)-Z''(phi))内旋欧拉角旋转(ntrinsic rotations) | |||
TRotation r; | |||
r.SetXEulerAngles(phi,theta,psi); | |||
</syntaxhighlight> |
2022年2月24日 (四) 12:41的版本
三维旋转矩阵
我们考虑主动旋转,并且通过$$\vec{r} = R\vec{r}$$定义相应的旋转矩阵$$R$$,其中$$\vec{r} = (x,y,z)^T$$,于是绕固定轴(世界轴)XYZ(extrinsic rotations)的旋转矩阵$$R$$为
$$ R(\phi,X) = \begin{pmatrix} 1&0&0 \\ 0&\cos(\phi) & -\sin(\phi) \\ 0& \sin(\phi) & \cos(\phi) \end{pmatrix}, R(\phi,Y) = \begin{pmatrix} \cos(\phi)&0&\sin(\phi) \\ 0&1&0 \\ -\sin(\phi)&0&\cos(\phi) \end{pmatrix}, R(\phi,Z) = \begin{pmatrix} \cos(\phi) & -\sin(\phi) & 0 \\ \sin(\phi) & \cos(\phi) & 0 \\ 0 & 0 & 1 \end{pmatrix} $$
于是连续两次绕世界轴旋转的旋转$$(Z(\phi)-X(\theta))$$的旋转矩阵为$$R(\theta,X)R(\phi,Z)$$
在ROOT中,TRotation即为旋转矩阵,使用方法如下
TRotation r;
//令r为绕轴TVector3(3,4,5)旋转Pi/3的旋转矩阵
r.Rotate(TMath::Pi()/3,TVector3(3,4,5));
//对向量v进行旋转r
TVector3 v;
TRotation r;
v.Transform(r);
v *= r; //Attention v = r * v
//变为恒等变换
r.SetToIdentity();
//得到绕固定轴Z旋转phi,再绕固定轴X旋转theta的旋转矩阵
r.RotateZ(phi)
r.RotateX(theta)
通过欧拉角表示三维旋转
考虑内旋(intrinsic rotations)定义下(即绕刚体轴旋转)的$$Z(\psi)-X'(\theta)-Z''(\phi)$$欧拉角旋转,依次旋转的角度为$$\psi,\theta,\phi$$,它与外旋(extrinsic rotations)定义下(即绕世界轴旋转)的欧拉角$$Z(\phi)-X(\theta)-Z(\psi)$$的旋转效果相同,旋转矩阵均为 $$ R_{ZX'Z''}(\psi,\theta,\phi) = R_{ZXZ}(\phi,\theta,\psi) = R(\psi,Z)R(\theta,X)R(\phi,Z)'' $$
在ROOT中构建欧拉角旋转的旋转矩阵
////////////////////////////////////////////////////////////////////////////////
/// Rotate using the x-convention.
TRotation & TRotation::RotateXEulerAngles(Double_t phi,
Double_t theta,
Double_t psi) {
TRotation euler;
euler.SetXEulerAngles(phi,theta,psi);
return Transform(euler);
}
////////////////////////////////////////////////////////////////////////////////
/// Rotate using the x-convention (Landau and Lifshitz, Goldstein, &c) by
/// doing the explicit rotations. This is slightly less efficient than
/// directly applying the rotation, but makes the code much clearer. My
/// presumption is that this code is not going to be a speed bottle neck.
TRotation & TRotation::SetXEulerAngles(Double_t phi,
Double_t theta,
Double_t psi) {
SetToIdentity();
RotateZ(phi);
RotateX(theta);
RotateZ(psi);
return *this;
}
///得到一个(Z(phi)-X(theta)-Z(psi))的外旋欧拉角旋转(extrinsic rotations)的旋转矩阵,即(Z(psi)-X'(theta)-Z''(phi))内旋欧拉角旋转(ntrinsic rotations)
TRotation r;
r.SetXEulerAngles(phi,theta,psi);