Skip to content

Instantly share code, notes, and snippets.

@machinaut
Last active April 1, 2019 13:56
Show Gist options
  • Save machinaut/29d0e21b544b4a36082c761c439144d6 to your computer and use it in GitHub Desktop.
Save machinaut/29d0e21b544b4a36082c761c439144d6 to your computer and use it in GitHub Desktop.
Simple Euler Angles Rotation in python
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