aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-11-12 18:03:12 +0100
committerThomas White <taw@physics.org>2009-11-12 18:03:12 +0100
commitc9a551b872ae4eb16a606d46a7cf118af24f75f5 (patch)
tree9c57f03f8acb742186796e0d3a55914b61183c65 /src/utils.c
parent2008d998a48301aef17c6247b17c4c5b92a87fdc (diff)
Loads of lattice stuff
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 38855671..fa239f90 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -122,3 +122,37 @@ int sign(double a)
if ( a > 0 ) return +1;
return 0;
}
+
+
+void mapping_rotate(double x, double y, double z,
+ double *ddx, double *ddy, double *ddz,
+ double omega, double tilt)
+{
+ double nx, ny, nz;
+ double x_temp, y_temp, z_temp;
+
+ /* First: rotate image clockwise until tilt axis is aligned
+ * horizontally. */
+ nx = x*cos(omega) + y*sin(omega);
+ ny = -x*sin(omega) + y*cos(omega);
+ nz = z;
+
+ /* Now, tilt about the x-axis ANTICLOCKWISE around +x, i.e. the
+ * "wrong" way. This is because the crystal is rotated in the
+ * experiment, not the Ewald sphere. */
+ x_temp = nx; y_temp = ny; z_temp = nz;
+ nx = x_temp;
+ ny = cos(tilt)*y_temp + sin(tilt)*z_temp;
+ nz = -sin(tilt)*y_temp + cos(tilt)*z_temp;
+
+ /* Finally, reverse the omega rotation to restore the location of the
+ * image in 3D space */
+ x_temp = nx; y_temp = ny; z_temp = nz;
+ nx = x_temp*cos(-omega) + y_temp*sin(-omega);
+ ny = -x_temp*sin(-omega) + y_temp*cos(-omega);
+ nz = z_temp;
+
+ *ddx = nx;
+ *ddy = ny;
+ *ddz = nz;
+}