简体   繁体   中英

Sympy direction of rotation matrices

I wonder why rotation matrices in sympy do not conform right hand rule:

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

produces output:

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

Which comparing to right hand rotation:

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

rotates vector in the opposite direction. This had taken me a few hours of searching for mistakes in my equations before I realized the problem.

Same is true for rot_axis2 and rot_axis1 .

In R^3, coordinate system rotations of the x-, y-, and z-axes in a counterclockwise direction when looking towards the origin give the matrices.

在此处输入图片说明

(Goldstein 1980, pp. 146-147 and 608; Arfken 1985, pp. 199-200)

Also if you check the 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM