球坐标与直角坐标的转换

             

Prerequisite 球坐标系的定义,四象限 Arctan 函数

   当我们讨论球坐标和直角坐标的转换时,通常令两个原点重合,取极轴($\theta = 0$)为 $z$ 轴的正方向,$\theta = \pi/2$,$\phi = 0$ 为 $x$ 轴的正方向,$\theta = \pi/2$,$\phi = \pi/2$ 为 $y$ 轴的正方向.这时两种坐标之间的变换关系为.

\begin{equation} \begin{cases} x = r\sin \theta \cos \phi \\ y = r\sin \theta \sin \phi \\ z = r\cos \theta \end{cases} \end{equation}
\begin{equation} \left\{\begin{aligned} r &= \sqrt {x^2 + y^2 + z^2} \\ \theta &= \operatorname{Arctan} \left(\sqrt{x^2 + y^2}, z \right) \\ \phi &= \operatorname{Arctan} (y, x) \end{aligned}\right. \end{equation}
其中 $ \operatorname{Arctan} $ 函数(也记为 $ \operatorname {atan2}$)的定义见eq. 1 .注意根据eq. 1 ,同一个直角坐标可以对应不同的极坐标,例如将 $\phi$ 增加 $2\pi$ 的整数倍,由例如对 $z$ 轴上的点 $\phi$ 可以取任意值.但根据eq. 2 ,我们可以找到两种坐标间的一一对应关系.

矢量的变换

   两组基底之间的变换关系为

\begin{equation} \begin{cases} \hat{\boldsymbol{\mathbf{r}}} = R_{11} \hat{\boldsymbol{\mathbf{x}}} + R_{12} \hat{\boldsymbol{\mathbf{y}}} + R_{13} \hat{\boldsymbol{\mathbf{z}}} \\ \hat{\boldsymbol{\mathbf{\theta}}} = R_{21} \hat{\boldsymbol{\mathbf{x}}} + R_{22} \hat{\boldsymbol{\mathbf{y}}} + R_{23} \hat{\boldsymbol{\mathbf{z}}} \\ \hat{\boldsymbol{\mathbf{\phi}}} = R_{31} \hat{\boldsymbol{\mathbf{x}}} + R_{32} \hat{\boldsymbol{\mathbf{y}}} + R_{33} \hat{\boldsymbol{\mathbf{z}}} \end{cases} \end{equation}
\begin{equation} \begin{cases} \hat{\boldsymbol{\mathbf{x}}} = R_{11} \hat{\boldsymbol{\mathbf{r}}} + R_{21} \hat{\boldsymbol{\mathbf{\theta}}} + R_{31} \hat{\boldsymbol{\mathbf{\phi}}} \\ \hat{\boldsymbol{\mathbf{y}}} = R_{12} \hat{\boldsymbol{\mathbf{r}}} + R_{22} \hat{\boldsymbol{\mathbf{\theta}}} + R_{32} \hat{\boldsymbol{\mathbf{\phi}}} \\ \hat{\boldsymbol{\mathbf{z}}} = R_{13} \hat{\boldsymbol{\mathbf{r}}} + R_{23} \hat{\boldsymbol{\mathbf{\theta}}} + R_{33} \hat{\boldsymbol{\mathbf{\phi}}} \end{cases} \end{equation}
其中 $ \boldsymbol{\mathbf{R}} $ 是关于两个角度的三维旋转矩阵
\begin{equation} \boldsymbol{\mathbf{R}} = \begin{pmatrix} \sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta\\ \cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta\\ -\sin\phi & \cos\phi & 0 \end{pmatrix} \end{equation}

   若任意矢量 $ \boldsymbol{\mathbf{v}} $ 在直角坐标系和球坐标系中分别表示为

\begin{equation} \boldsymbol{\mathbf{v}} = v_x \hat{\boldsymbol{\mathbf{x}}} + v_y \hat{\boldsymbol{\mathbf{y}}} + v_z \hat{\boldsymbol{\mathbf{z}}} \end{equation}
\begin{equation} \boldsymbol{\mathbf{v}} = v_r \hat{\boldsymbol{\mathbf{r}}} + v_\theta \hat{\boldsymbol{\mathbf{\theta}}} + v_\phi \hat{\boldsymbol{\mathbf{\phi}}} \end{equation}
则坐标变换关系可以用矩阵乘法表示
\begin{equation} \begin{pmatrix}v_r \\ v_\theta \\ v_\phi\end{pmatrix} = \boldsymbol{\mathbf{R}} \begin{pmatrix}v_x \\ v_y \\ v_z\end{pmatrix} \end{equation}
\begin{equation} \begin{pmatrix}v_x \\ v_y \\ v_z\end{pmatrix} = \boldsymbol{\mathbf{R}} ^{\mathrm{T}} \begin{pmatrix}v_r \\ v_\theta \\ v_\phi\end{pmatrix} \end{equation}

推导

   把空间中一点 $P$ 的位矢 $r \, \hat{\boldsymbol{\mathbf{r}}} $ 分解为垂直于 $xy$ 平面的分量 $z = r\cos \theta $ 和 $xy$ 平面的分量 $r\sin \theta $.后者又可以进而分解成 $x$ 分量 和 $y$ 分量 $x = r\sin \theta \cos \phi$, $y = r\sin \theta \sin \phi$,这就得到了eq. 1

   在直角坐标系中,有 $r = \sqrt {x^2 + y^2 + z^2}$,代入eq. 1 中的三条关系,就可以很容易解出eq. 2 中的三条关系.

   现在推导变换关系(eq. 3 ).由于 $ \hat{\boldsymbol{\mathbf{r}}} , \hat{\boldsymbol{\mathbf{\theta}}} , \hat{\boldsymbol{\mathbf{\phi}}} $ 都是关于 $(r, \theta, \phi)$ 的函数,所以在考察一点 $(r, \theta, \phi)$ 时,$ \hat{\boldsymbol{\mathbf{r}}} $ 的球坐标是 $(1, \theta, \phi)$, 根据eq. 1 变换到直角坐标为

\begin{equation} (\sin \theta \cos \phi,\,\sin \theta \sin \phi,\,\cos \theta) \end{equation}
写成矢量的形式,就是
\begin{equation} \hat{\boldsymbol{\mathbf{r}}} = \sin \theta \cos \phi \, \hat{\boldsymbol{\mathbf{x}}} + \sin \theta \sin \phi \, \hat{\boldsymbol{\mathbf{y}}} + \cos \theta \, \hat{\boldsymbol{\mathbf{z}}} \end{equation}
至于eq. 3 的第二条式子,在同一个球坐标 $(r,\theta ,\phi)$ 处,$ \hat{\boldsymbol{\mathbf{\theta}}} $ 的球坐标为 $(1, \theta + \pi /2, \phi)$,根据eq. 1 变换到直角坐标再化简就得到直角坐标和对应的矢量形式为
\begin{equation} (\cos \theta \cos \phi ,\,\cos \theta \sin \phi , \,- \sin \theta) \end{equation}
\begin{equation} \hat{\boldsymbol{\mathbf{\theta}}} = \cos \theta \cos \phi \, \hat{\boldsymbol{\mathbf{x}}} + \cos \theta \sin \phi \, \hat{\boldsymbol{\mathbf{y}}} - \sin \theta \, \hat{\boldsymbol{\mathbf{z}}} \end{equation}
同理可得eq. 5 .将基底变换eq. 3 eq. 4 分别代入eq. 7 eq. 6 得坐标变换eq. 9 eq. 8

两方向的夹角

Prerequisite 内积

   若已知球坐标系中两个方向分别为 $(1, \theta_1, \phi_1)$ 和 $(1, \theta_2, \phi_2)$ 如何求它们之间的夹角 $\alpha$ 呢?我们可以先计算两个单位矢量的直角坐标,然后对它们进行内积即可得到两矢量夹角的余弦值.由eq. 1 ,两矢量的直角坐标分别为

\begin{equation} (\sin\theta_1\cos\phi_1,\ \sin\theta_1\sin\phi_1,\ \cos\theta_1) \qquad (\sin\theta_2\cos\phi_2,\ \sin\theta_2\sin\phi_2,\ \cos\theta_2) \end{equation}
利用三角恒等式(eq. 4 ),得
\begin{equation} \begin{aligned} \cos\alpha &= \sin\theta_1\cos\phi_1\sin\theta_2\cos\phi_2 + \sin\theta_1\sin\phi_1 \sin\theta_2\sin\phi_2 + \cos\theta_1 \cos\theta_2\\ &= \sin\theta_1\sin\theta_2(\cos\phi_1 \cos\phi_2 + \sin\phi_1\sin\phi_2) + \cos\theta_1 \cos\theta_2\\ &= \sin\theta_1\sin\theta_2 \cos\left(\phi_2-\phi_1\right) + \cos\theta_1 \cos\theta_2\\ \end{aligned} \end{equation}

         

© 小时科技 保留一切权利