坐标系绕y轴旋转变换公式
时间: 2025-07-08 20:34:06 浏览: 7
坐标系绕 y 轴旋转的变换公式可以通过旋转矩阵来表示。对于一个三维空间中的点 $ P = (x, y, z) $,当它绕 y 轴旋转角度 $ \theta $(以弧度为单位)时,其变换后的坐标 $ P' = (x', y', z') $ 可通过以下公式计算:
$$
\begin{aligned}
x' &= x \cdot \cos(\theta) - z \cdot \sin(\theta) \\
y' &= y \\
z' &= x \cdot \sin(\theta) + z \cdot \cos(\theta)
\end{aligned}
$$
该变换对应的旋转矩阵为:
$$
R_y(\theta) =
\begin{bmatrix}
\cos(\theta) & 0 & \sin(\theta) \\
0 & 1 & 0 \\
-\sin(\theta) & 0 & \cos(\theta)
\end{bmatrix}
$$
当对一个向量或点进行旋转操作时,只需要将该点的坐标写成列向量形式,并与上述矩阵相乘即可得到旋转后的结果[^2]。
### 示例代码
以下是一个使用 Python 进行绕 y 轴旋转的示例代码:
```python
import numpy as np
def rotate_y(theta):
"""
绕 y 轴旋转的旋转矩阵
:param theta: 旋转角度(以弧度为单位)
:return: 旋转矩阵
"""
return np.array([
[np.cos(theta), 0, np.sin(theta)],
[0, 1, 0],
[-np.sin(theta), 0, np.cos(theta)]
])
# 示例:绕 y 轴旋转 45 度
theta = np.radians(45)
rotation_matrix = rotate_y(theta)
# 原始点坐标
point = np.array([1, 2, 3])
# 计算旋转后的坐标
rotated_point = np.dot(rotation_matrix, point)
print("原始点:", point)
print("旋转后的点:", rotated_point)
```
### 结果解释
- `rotate_y(theta)` 函数生成了一个绕 y 轴旋转的旋转矩阵。
- 输入点 `(1, 2, 3)` 被旋转后,输出新的坐标值。
阅读全文
相关推荐


















