2017-04-15 106 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)