Skip to content
Snippets Groups Projects
Commit e549e300 authored by kpetersn's avatar kpetersn
Browse files

Implemented 3d rotation transform with angles in radians

git-svn-id: https://subversion.xray.aps.anl.gov/kmp/transform/trunk@210 f095f811-4e88-6c84-d33e-e382bdb4531c
parent 909aab1b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
import transform
from numpy import matrix, sin, cos
class myTransform(transform.transform):
### The transform functions should be overloaded for each application
......@@ -12,13 +13,39 @@ class myTransform(transform.transform):
# Transform real coordinates into soft coordinates
def fwdTrans(self, m_positions, t_positions):
retval = [m_positions[x] * t_positions[x] for x in range(3)]
return retval[:]
""" """
m_matrix = matrix(m_positions)
th, phi, chi = t_positions
Rx = matrix([[1, 0, 0],[0, cos(th), sin(th)], [0, -sin(th), cos(th)]])
Ry = matrix([[cos(phi), 0, -sin(phi)], [0, 1, 0], [sin(phi), 0, cos(phi)]])
Rz = matrix([[cos(chi), sin(chi), 0], [-sin(chi), cos(chi), 0], [0, 0, 1]])
R = Rx * Ry * Rz
# Inverse is R.I
retval = m_matrix * R
print retval
return retval.tolist()[0]
# Transform soft coordinates into real coordinates
def invTrans(self, tm_positions, t_positions):
retval = [tm_positions[x] / t_positions[x] for x in range(3)]
return retval[:]
""" """
tm_matrix = matrix(tm_positions)
th, phi, chi = t_positions
Rx = matrix([[1, 0, 0],[0, cos(th), sin(th)], [0, -sin(th), cos(th)]])
Ry = matrix([[cos(phi), 0, -sin(phi)], [0, 1, 0], [sin(phi), 0, cos(phi)]])
Rz = matrix([[cos(chi), sin(chi), 0], [-sin(chi), cos(chi), 0], [0, 0, 1]])
R = Rx * Ry * Rz
retval = tm_matrix * R.I
print retval
return retval.tolist()[0]
if __name__ == "__main__":
prefix = 'kmp2:'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment