Created
August 10, 2018 13:20
-
-
Save rfzeg/879ece8fc9a76f0468bdf9ae64dd522a to your computer and use it in GitHub Desktop.
Finds the angles alpha, beta, and gamma, given that numerical values for a rotation matrix are known.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment