坐标旋转变换 公式图解

坐标系绕 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)` 被旋转后,输出新的坐标值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值