Created
October 29, 2012 01:35
-
-
Save tacaswell/3970893 to your computer and use it in GitHub Desktop.
A simple function that implements rotation by Euler angles.
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment