Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import numpy as np
- from sympy.matrices import Matrix
- from sympy import symbols, atan2, sqrt
- # Conversion Factors
- rtd = 180./np.pi # radians to degrees
- # Fixed Axis X-Y-Z Rotation Matrix
- R_XYZ = Matrix([[ 0.353553390593274, -0.306186217847897, 0.883883476483184],
- [ 0.353553390593274, 0.918558653543692, 0.176776695296637],
- [-0.866025403784439, 0.25, 0.433012701892219]])
- # Calculate the Euler angles that produces a rotation equivalent to R (above)
- # NOTE: the answer has units of DEGREES!
- alpha = rtd*atan2(R_XYZ[1,0],R_XYZ[0,0]) # rotation about Z-axis
- beta = rtd*atan2(-R_XYZ[2,0],sqrt(R_XYZ[0,0]**2+R_XYZ[1,0]**2)) # rotation about Y-axis
- gamma = rtd*atan2(R_XYZ[2,1],R_XYZ[2,2]) # rotation about X-axis
Add Comment
Please, Sign In to add comment