Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sympy direction of rotation matrices

Tags:

python

sympy

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.

like image 637
Long Smith Avatar asked Oct 29 '25 11:10

Long Smith


1 Answers

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.

enter image description here

(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)
like image 186
eyllanesc Avatar answered Oct 31 '25 01:10

eyllanesc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!