二维坐标旋转变换矩阵
时间: 2025-05-31 21:46:36 浏览: 25
### 二维坐标旋转变换矩阵的数学推导与实现
#### 推导过程
假设有一个点 \( P(x, y) \) 在平面直角坐标系中,将其绕原点逆时针旋转角度 \( \theta \),得到新的点 \( P'(x', y') \)[^1]。根据三角函数定义:
\[
x' = x \cdot \cos(\theta) - y \cdot \sin(\theta)
\]
\[
y' = x \cdot \sin(\theta) + y \cdot \cos(\theta)
\][^3]
为了便于理解和应用,可以将上述公式写成矩阵形式:
\[
\begin{bmatrix}
x' \\
y'
\end{bmatrix} =
\begin{bmatrix}
\cos(\theta) & -\sin(\theta) \\
\sin(\theta) & \cos(\theta)
\end{bmatrix}
\begin{bmatrix}
x \\
y
\end{bmatrix}[^1]
\]
其中,
\[
R(\theta) =
\begin{bmatrix}
\cos(\theta) & -\sin(\theta) \\
\sin(\theta) & \cos(\theta)
\end{bmatrix}
\]
称为二维旋转矩阵。
---
#### 实现代码
以下是基于 Python 的二维坐标旋转变换矩阵实现代码:
```python
import numpy as np
def rotate_point_2d(point, theta):
"""
对给定点进行二维平面上的旋转变换
参数:
point (list or tuple): 原始点的坐标 (x, y)
theta (float): 旋转角度(弧度制)
返回:
list: 旋转后的点坐标 [x', y']
"""
rotation_matrix = np.array([
[np.cos(theta), -np.sin(theta)],
[np.sin(theta), np.cos(theta)]
])
original_vector = np.array([[point[0]], [point[1]]])
rotated_vector = np.dot(rotation_matrix, original_vector)
return rotated_vector.flatten().tolist()
# 测试例子
original_point = (1, 0) # 初始点
angle_degrees = 90 # 旋转角度(单位:度数)
angle_radians = np.radians(angle_degrees)
rotated_point = rotate_point_2d(original_point, angle_radians)
print(f"原始点 {original_point} 经过 {angle_degrees}° 旋转后变为 {tuple(rotated_point)}")
```
运行结果如下:
对于初始点 \( (1, 0) \) 和旋转角度 \( 90^\circ \),输出为 \( (0.0, 1.0) \)[^4]。
---
#### 应用场景
二维旋转变换广泛应用于计算机图形学、机器人运动规划以及地理信息系统等领域。例如,在地图投影过程中,可能需要将地球表面的一个区域从一种坐标系映射到另一种坐标系,此时会涉及大量的旋转变换操作[^3]。
---
阅读全文
相关推荐


















