# 矩阵旋转

> source: 文章/matrix-rotation/index.md

# 矩阵旋转

矩阵的旋转变换是线性变换中的一种特殊情况，它因为只改变目标的方向而不改变大小和形状而有广泛的应用

为什么旋转矩阵长这个样子？

<!-- more -->

在二位平面内使用矩阵进行旋转，可以使用以下的方式：

$$
\begin{bmatrix}
{\cos \theta}&{-\sin \theta}\\
{\sin \theta}&{\cos \theta}\\
\end{bmatrix}
$$

在本文的开头，我们将简单推导一下为什么这个形式的矩阵能用来旋转，并且在之后，我会给出其他具有旋转特性的数学方法。上面的这种表示方法为什么能代表旋转呢？我在真正理解的时候还是在学习[主成分分析](https://zh.wikipedia.org/wiki/%E4%B8%BB%E6%88%90%E5%88%86%E5%88%86%E6%9E%90)的时候，参考up主[同济交通小旭学长](https://space.bilibili.com/3051484)的视频：

<iframe width="560" height="315" src="//player.bilibili.com/player.html?aid=459231629&bvid=BV1E5411E71z&cid=297079639&p=1&autoplay=0&muted=true" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

我们假设一组基：$i = \begin{bmatrix}{1}\\{0} \end{bmatrix}, j = \begin{bmatrix}{0}\\{1} \end{bmatrix}$，使这一组基旋转$\theta$角度，可以得到：
$$
\begin{align}
\hat i &=\begin{bmatrix}{\cos \theta}\\{\sin \theta} \end{bmatrix} \\
\hat j &=\begin{bmatrix}{\cos (\theta+\frac{\pi}{2})}\\{\sin (\theta+\frac{\pi}{2})} \end{bmatrix}= \begin{bmatrix}{-\sin \theta}\\{\cos \theta} \end{bmatrix}
\end{align}
$$
因此可以发现，矩阵是对这两组基的作用，事实上，我们可以认为这两组基构建了整个线性空间，矩阵通过线性变换这两组基变换了整个线性空间



除此以外，与旋转有关的数学概念和方法还有：

- 四元数
- 欧拉公式
- 复数

## References

1. [3维旋转矩阵推导与助记](https://zhuanlan.zhihu.com/p/183973440)
2. [Donut math: how donut.c works](https://www.a1k0n.net/2011/07/20/donut-math.html)
3. [用最直观的方式告诉你：什么是主成分分析PCA](https://www.bilibili.com/video/BV1E5411E71z/)
