Last active
April 1, 2019 13:56
-
-
Save machinaut/29d0e21b544b4a36082c761c439144d6 to your computer and use it in GitHub Desktop.
Simple Euler Angles Rotation in python
This file contains hidden or 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
import numpy as np | |
from scipy.linalg import expm | |
def rot_euler(v, xyz): | |
''' Rotate vector v (or array of vectors) by the euler angles xyz ''' | |
# https://stackoverflow.com/questions/6802577/python-rotation-of-3d-vector | |
for theta, axis in zip(xyz, np.eye(3)): | |
v = np.dot(np.array(v), expm(np.cross(np.eye(3), axis*-theta))) | |
return v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment