2017-04-15 281 views
0

我不知道爲什麼在sympy旋轉矩陣不符合右手法則:Sympy方向矩陣

import sympy as sym 
print(sym.rot_axis3(sym.Symbol('q'))) 

產生輸出:

[[ cos(q), sin(q), 0], 
[-sin(q), cos(q), 0], 
[0,  0,  1]] 

哪個比較右手旋轉:

[[cos(q), -sin(q), 0], 
[sin(q), cos(q), 0], 
[0,  0,  1]] 

旋轉在相反的方向矢量。這帶我在尋找我的方程的錯誤我才意識到了問題的幾個小時。

同樣是rot_axis2rot_axis1如此。

+1

檢查這:http://mathworld.wolfram.com/RotationMatrix.html,R_z = rot_axis3和http://docs.sympy.org/dev/_modules/sympy/matrices/dense.html – eyllanesc

+0

@eyllanesc非常感謝!甚至不知道這樣一個約定。如果你寫一個答案,我將應用它。 –

+0

我已經寫了我的答案。 – eyllanesc

回答

1

在R^3中,當朝向原點看時,逆時針方向上的x,y和z軸座標系旋轉給出矩陣。

enter image description here

(戈爾茨坦1980,第146-147和608; Arfken 1985年,199-200頁。)

此外,如果你檢查sympy documentation

def rot_axis3(theta): 
    """Returns a rotation matrix for a rotation of theta (in radians) about 
    the 3-axis. 
    [...] 
    """ 
    ct = cos(theta) 
    st = sin(theta) 
    lil = ((ct, st, 0), 
      (-st, ct, 0), 
      (0, 0, 1)) 
    return Matrix(lil)