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

Modified my transform functions to accept angles in degrees instead of radians.

git-svn-id: https://subversion.xray.aps.anl.gov/kmp/transform/trunk@211 f095f811-4e88-6c84-d33e-e382bdb4531c
parent e549e300
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python #!/usr/bin/env python
import transform import transform
from numpy import matrix, sin, cos from numpy import matrix, sin, cos, degrees, radians
class myTransform(transform.transform): class myTransform(transform.transform):
### The transform functions should be overloaded for each application ### The transform functions should be overloaded for each application
...@@ -15,7 +15,7 @@ class myTransform(transform.transform): ...@@ -15,7 +15,7 @@ class myTransform(transform.transform):
def fwdTrans(self, m_positions, t_positions): def fwdTrans(self, m_positions, t_positions):
""" """ """ """
m_matrix = matrix(m_positions) m_matrix = matrix(m_positions)
th, phi, chi = t_positions th, phi, chi = [radians(x) for x in t_positions]
Rx = matrix([[1, 0, 0],[0, cos(th), sin(th)], [0, -sin(th), cos(th)]]) 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)]]) 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]]) Rz = matrix([[cos(chi), sin(chi), 0], [-sin(chi), cos(chi), 0], [0, 0, 1]])
...@@ -26,7 +26,7 @@ class myTransform(transform.transform): ...@@ -26,7 +26,7 @@ class myTransform(transform.transform):
retval = m_matrix * R retval = m_matrix * R
print retval #!print retval
return retval.tolist()[0] return retval.tolist()[0]
...@@ -34,7 +34,7 @@ class myTransform(transform.transform): ...@@ -34,7 +34,7 @@ class myTransform(transform.transform):
def invTrans(self, tm_positions, t_positions): def invTrans(self, tm_positions, t_positions):
""" """ """ """
tm_matrix = matrix(tm_positions) tm_matrix = matrix(tm_positions)
th, phi, chi = t_positions th, phi, chi = [radians(x) for x in t_positions]
Rx = matrix([[1, 0, 0],[0, cos(th), sin(th)], [0, -sin(th), cos(th)]]) 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)]]) 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]]) Rz = matrix([[cos(chi), sin(chi), 0], [-sin(chi), cos(chi), 0], [0, 0, 1]])
...@@ -43,7 +43,7 @@ class myTransform(transform.transform): ...@@ -43,7 +43,7 @@ class myTransform(transform.transform):
retval = tm_matrix * R.I retval = tm_matrix * R.I
print retval #!print retval
return retval.tolist()[0] return retval.tolist()[0]
......
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