SharedEulerMatrix.sagewsOpen in CoCalc

Assumptions

Reference frame

+X = Right, +Y = Up, +Z = Back

Euler rotations

Order: Pitch (X), Yaw (Y), Roll (Z)


(x, y, z) = var('theta_x, theta_y, theta_z')

Rx = Matrix([
    [1,      0,       0],
    [0, cos(x), -sin(x)],
    [0, sin(x),  cos(x)]
])

Ry = Matrix([
    [ cos(y), 0, sin(y)],
    [      0, 1,      0],
    [-sin(y), 0, cos(y)]
])

Rz = Matrix([
    [cos(z), -sin(z), 0],
    [sin(z),  cos(z), 0],
    [     0,       0, 1]
])

show( '$R_x=$', Rx, '$, R_y=$', Ry, '$, R_z=$', Rz )
show( '$R_x R_y R_z=$', Rx * Ry * Rz )

Rx=R_x= (1000cos(θx)sin(θx)0sin(θx)cos(θx))\displaystyle \left(\begin{array}{rrr} 1 & 0 & 0 \\ 0 & \cos\left(\theta_{x}\right) & -\sin\left(\theta_{x}\right) \\ 0 & \sin\left(\theta_{x}\right) & \cos\left(\theta_{x}\right) \end{array}\right) ,Ry=, R_y= (cos(θy)0sin(θy)010sin(θy)0cos(θy))\displaystyle \left(\begin{array}{rrr} \cos\left(\theta_{y}\right) & 0 & \sin\left(\theta_{y}\right) \\ 0 & 1 & 0 \\ -\sin\left(\theta_{y}\right) & 0 & \cos\left(\theta_{y}\right) \end{array}\right) ,Rz=, R_z= (cos(θz)sin(θz)0sin(θz)cos(θz)0001)\displaystyle \left(\begin{array}{rrr} \cos\left(\theta_{z}\right) & -\sin\left(\theta_{z}\right) & 0 \\ \sin\left(\theta_{z}\right) & \cos\left(\theta_{z}\right) & 0 \\ 0 & 0 & 1 \end{array}\right)
RxRyRz=R_x R_y R_z= (cos(θy)cos(θz)cos(θy)sin(θz)sin(θy)cos(θz)sin(θx)sin(θy)+cos(θx)sin(θz)sin(θx)sin(θy)sin(θz)+cos(θx)cos(θz)cos(θy)sin(θx)cos(θx)cos(θz)sin(θy)+sin(θx)sin(θz)cos(θx)sin(θy)sin(θz)+cos(θz)sin(θx)cos(θx)cos(θy))\displaystyle \left(\begin{array}{rrr} \cos\left(\theta_{y}\right) \cos\left(\theta_{z}\right) & -\cos\left(\theta_{y}\right) \sin\left(\theta_{z}\right) & \sin\left(\theta_{y}\right) \\ \cos\left(\theta_{z}\right) \sin\left(\theta_{x}\right) \sin\left(\theta_{y}\right) + \cos\left(\theta_{x}\right) \sin\left(\theta_{z}\right) & -\sin\left(\theta_{x}\right) \sin\left(\theta_{y}\right) \sin\left(\theta_{z}\right) + \cos\left(\theta_{x}\right) \cos\left(\theta_{z}\right) & -\cos\left(\theta_{y}\right) \sin\left(\theta_{x}\right) \\ -\cos\left(\theta_{x}\right) \cos\left(\theta_{z}\right) \sin\left(\theta_{y}\right) + \sin\left(\theta_{x}\right) \sin\left(\theta_{z}\right) & \cos\left(\theta_{x}\right) \sin\left(\theta_{y}\right) \sin\left(\theta_{z}\right) + \cos\left(\theta_{z}\right) \sin\left(\theta_{x}\right) & \cos\left(\theta_{x}\right) \cos\left(\theta_{y}\right) \end{array}\right)

show( Rx.subs( x == pi/2 ), Ry.subs( y == pi/2 ), Rz.subs( z == pi/2 ) )

(100001010)\displaystyle \left(\begin{array}{rrr} 1 & 0 & 0 \\ 0 & 0 & -1 \\ 0 & 1 & 0 \end{array}\right) (001010100)\displaystyle \left(\begin{array}{rrr} 0 & 0 & 1 \\ 0 & 1 & 0 \\ -1 & 0 & 0 \end{array}\right) (010100001)\displaystyle \left(\begin{array}{rrr} 0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{array}\right)