public
Last active

A simple function that implements rotation by Euler angles.

  • Download Gist
euler_rot.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import numpy as np
def euler_rot(XYZ,phi,theta,psi):
'''Returns the points XYZ rotated by the given euler angles'''
 
 
ERot = np.array([[np.cos(theta)*np.cos(psi),
-np.cos(phi)*np.sin(psi) + np.sin(phi)*np.sin(theta)*np.cos(psi),
np.sin(phi)*np.sin(psi) + np.cos(phi)*np.sin(theta)*np.cos(psi)],
[np.cos(theta)*np.sin(psi),
np.cos(phi)*np.cos(psi) + np.sin(phi)*np.sin(theta)*np.sin(psi),
-np.sin(phi)*np.cos(psi) + np.cos(phi)*np.sin(theta)*np.sin(psi)],
[-np.sin(theta),
np.sin(phi)*np.cos(theta),
np.cos(phi)*np.cos(theta)]])
 
return ERot.dot(XYZ)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.