python - 转换一个刚性变换,使旋转中心不是原点
问题描述
给定一个旋转矩阵R
,什么是等价变换,使得某个点c
(新的旋转中心)在变换下不变y = R * c
,即改变R
,使得旋转中心在c
原点而不是原点。一个限制是我不能对要使用的实际向量进行操作,只能编辑原始转换(这是因为该部分隐藏在外部库中,我无法更改它)。
我有一些可行的方法,但它违反了上述限制:
import numpy as np
# R is a given rotation matrix, v is an arbitrary vector and cen is the desired center
theta = np.pi / 2
cen = np.array([0.5, 0.5])
v = np.array([0, 0])
R = Rot(theta) # ordinary rotation matrix
y = R @ (v - center ) + cen
# y = [0, 1] which is the expected result since we have a right angle triangle
# with vertices at (0, 0) (0.5, 0.5) and (0, 1)
我也尝试实现类似于此处的计算,但我得到的结果不正确
我怎样才能获得相同的结果但保持形式y = R*v
(或使用刚性变换y = R*v + t
)但v
不像我那样改变?
解决方案
在写这个问题时,我遇到了(明显的)解决方案,它只是扩展了我之前写的解决方案并重新排列。如果有人也需要这个,新的转换应该是:
y = R_new*v + t_new
其中R_new = R
,是恒等式t_new = (I - R)*cen
。I
推荐阅读
- python - 使用 Python 插入 Teradata 时日期无效
- c++ - QObject::connect 无法将信号连接到 *this* 对象的插槽
- javascript - 在卸载之前动画出一个 React 组件,它丢失了它需要显示的道具数据?
- sql - 循环遍历表定义和删除
- javascript - 打印预览页时文本截断
- c++ - QT 插槽未在主线程上被调用
- django - 芹菜工人不停
- python - 使用 Python 或 Map reduce 从 BIG File 中删除不需要的记录
- c - 索引到 C 中某些“枚举”类型的值数组
- ajax - ExtJS 在 Cookie 中存储 Ajax 查询并加载