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 )


$R_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)$ $, R_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)$ $, R_z=$ $\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)$
$R_x R_y R_z=$ $\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 ) )


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