首页 > 解决方案 > 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.

标签: pythonmatrix

解决方案


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 

推荐阅读