坐标旋转变换公式的推导

翻译自: http://www.metro-hs.ac.jp/rs/sinohara/zahyou_rot/zahyou_rotate.htm
翻译:  汤 永康
出处: http://blog.youkuaiyun.com/tangyongkang
转贴请注明出处
1 围绕原点的旋转
如下图, 在2维坐标上,有一点p(x, y) , 直线opの长度为r, 直线op和x轴的正向的夹角为a。 直线op围绕原点做逆时针方向b度的旋转,到达p’ (s,t) 

 

s = r cos(a + b) = r cos(a)cos(b) – r sin(a)sin(b)   (1.1)
t = r sin(a + b) = r sin(a)cos(b) + r cos(a) sin(b)  (1.2)
其中 x = r cos(a)  , y = r sin(a)
代入(1.1), (1.2) ,
s = x cos(b) – y sin(b)    (1.3)
t = x sin(b) + y cos(b)    (1.4)

 


用行列式表达如下:

 

2.座标系的旋转
在原坐标系xoy中,  绕原点沿逆时针方向旋转theta度, 变成座标系 sot。
设有某点p,在原坐标系中的坐标为 (x, y), 旋转后的新坐标为(s, t)。
 


oa = y sin(theta)   (2.1)
as = x cos(theta)   (2.2)
综合(2.1),(2.2) 2式
s =  os = oa + as = x cos(theta) + y sin(theta) 
t =  ot = ay – ab = y cos(theta) – x sin(theta)

 

用行列式表达如下:

转载于http://blog.youkuaiyun.com/tangyongkang/article/details/5484636

### 二维坐标旋转变换矩阵的数学推导与实现 #### 推导过程 假设有一个点 \( 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]。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值