python - Finding rotation matrix to transform one (3-vector) basis to another in 3d
问题描述
We have basis in 3d, Vx
= (1,0,0), Vy
= (0,1,0), Vz
=(0,0,1), which is transforming by (rotation) matrix M to Vx'
, Vy'
, Vz'
respectively. So we have 3 equations:
M * Vx = Vx'
M * Vy = Vy'
M * Vz = Vz'
Thus we have 9 linear equations for 9 components of matrix M.
Now I need to transform this equation in form A * m = b
(to solve it with numpy i.e.), where m is column-vectors of unknown M
components like [m11, m12, m13, m21, ...]
, A
is coefficients matrix, b
is coefficients column-vector.
So the question is, what are formulas for A
and b
? Is it possible to write some matrix formulas for it?
=== UPDATE
I got 'Notable question' prize for this question so I am updating it to unblock. Please note the question is quite precise and I am not searching any tool, the phrase 'Or, is there any tool which will help to write per-component formulas?' is just small addition which is not matter a lot I think.
解决方案
You set V0 = np.array([Vx,Vy,Vz])
for the old basis, V1 = np.array([Vx1,Vy1,Vz1])
for the new basis, where the basis vectors are the matrix rows and have the relation for the transposed matrices where the basis vectors are the columns
M * V0.T = V1.T <==> V0 * M.T = V1
This can be nicely solved as
M = np.linalg.solve(V0,V1).T
推荐阅读
- php - 使用 Laravel 的 Eloquent 向数据库发送数据的问题
- javascript - 根据用户选择显示表单字段,但不会提交值
- date - Google Sheets FILTER 公式大于 TODAY()
- android - 即使调用活动被破坏(在当前活动中)如何获取服务回调
- python - 生成对抗网络收敛错误
- jquery - 使用当前窗口高度自动计算 scaleTop
- python - 请求模块大文件的理想块大小?
- azure - Azure 上的 SSIS - 如何在 Azure 上执行流程任务?
- node.js - 有没有办法在 MongoDB 查询中动态设置我的字段值?
- xacml - 如何在 Axiomatics 中编写“If..then”条件