python - 在 Python 中旋转 3D 点
问题描述
我目前正在尝试旋转四个点以使其位置与另一组四个点相匹配。我使用 3D 旋转矩阵来执行此操作。但我得到以下问题:
旋转后点之间的距离会发生变化,我不明白为什么。
squared_dist = np.sum((tarll-tarul)**2, axis=0)
dist2 = np.sqrt(squared_dist)
print(dist2)
theta = -0.46
tarlr[0] = tarlr[0] * math.cos(theta) - tarlr[1] * math.sin(theta)
tarlr[1] = tarlr[0] * math.sin(theta) + tarlr[1] * math.cos(theta)
tarlr[2] = tarlr[2]
tarll[0] = tarll[0] * math.cos(theta) - tarll[1] * math.sin(theta)
tarll[1] = tarll[0] * math.sin(theta) + tarll[1] * math.cos(theta)
tarll[2] = tarll[2]
tarur[0] = tarur[0] * math.cos(theta) - tarur[1] * math.sin(theta)
tarur[1] = tarur[0] * math.sin(theta) + tarur[1] * math.cos(theta)
tarur[2] = tarur[2]
tarul[0] = tarul[0] * math.cos(theta) - tarul[1] * math.sin(theta)
tarul[1] = tarul[0] * math.sin(theta) + tarul[1] * math.cos(theta)
tarul[2] = tarul[2]
squared_dist = np.sum((tarll-tarul)**2, axis=0)
dist3 = np.sqrt(squared_dist)
print(dist3)
要点是:
#Tar position
tarlr = np.array([2.5679,3.5465,3.9583])
tarur = np.array([5.0263,-0.3365,3.9411])
tarul = np.array([1.1462,-2.7898,3.9491])
tarll = np.array([-1.3130,1.0835,3.9638])
#old Parameter
tarllOld = np.array([-2.4708,2.3395,4.101])
tarlrOld = np.array([2.1218,2.5116,4.0952])
tarurOld = np.array([2.2889,-2.0805,4.0774])
tarulOld = np.array([-2.2992,-2.2462,4.0859])
解决方案
推荐阅读
- mysql - 如何设置包含当前日期的日期范围的 BigQuery 查询
- sql - 存储过程
- kotlin - 问:在 Jupyter notebook 中找不到 Kotlin 内核
- python - Python:来自 websockets 的多线程实时数据流不起作用
- android - 为什么我无法从 Json Array 中获取数据
- java - 在图像编辑器中在 Swing 中倒置加载的图像看起来很完美
- amazon-web-services - SSH 进入 AWS lightsail 登录后直接随机冻结
- influxdb - “显示标签值”在 CLI 和 Web API 之间产生不同的结果
- linux - 如何让 apache 让我们编写 url 子域但使用 url 就像不是子域
- java - 播放 4 秒视频后,Seekbar 消失。触摸屏幕时不显示。它仅显示开始 4 秒和仅完成时间