diff options
author | Thomas White <taw@physics.org> | 2010-11-15 16:17:02 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:05 +0100 |
commit | 1b4fa114decd9c36324feed00296cb40088a9062 (patch) | |
tree | 2d313458c29c6f4ac5de5513639020558eaaa556 /src | |
parent | fcde5d4f2fd95845402b86c3838f15b6632a8071 (diff) |
Zap quats
The "orientation" quaternion should not rotate the Ewald sphere, but the crystal.
This cleans things up a little, removing "orientation" from "struct image".
Diffstat (limited to 'src')
-rw-r--r-- | src/calibrate_detector.c | 6 | ||||
-rw-r--r-- | src/cell.c | 22 | ||||
-rw-r--r-- | src/cell.h | 4 | ||||
-rw-r--r-- | src/cubeit.c | 6 | ||||
-rw-r--r-- | src/detector.c | 2 | ||||
-rw-r--r-- | src/diffraction-gpu.c | 6 | ||||
-rw-r--r-- | src/facetron.c | 4 | ||||
-rw-r--r-- | src/image.h | 1 | ||||
-rw-r--r-- | src/indexamajig.c | 12 | ||||
-rw-r--r-- | src/pattern_sim.c | 27 | ||||
-rw-r--r-- | src/peaks.c | 3 | ||||
-rw-r--r-- | src/reintegrate.c | 6 |
12 files changed, 45 insertions, 54 deletions
diff --git a/src/calibrate_detector.c b/src/calibrate_detector.c index b20b1619..7feeb16c 100644 --- a/src/calibrate_detector.c +++ b/src/calibrate_detector.c @@ -172,12 +172,6 @@ static void add_image(void *args, int cookie) image.n_cpeaks = 0; image.det = NULL; - /* View head-on (unit cell is tilted) */ - image.orientation.w = 1.0; - image.orientation.x = 0.0; - image.orientation.y = 0.0; - image.orientation.z = 0.0; - STATUS("%3i: Processing '%s'\n", cookie, pargs->filename); hdfile = hdfile_open(pargs->filename); @@ -486,6 +486,28 @@ static const char *cell_rep(UnitCell *cell) } +UnitCell *cell_rotate(UnitCell *in, struct quaternion quat) +{ + struct rvec a, b, c; + struct rvec an, bn, cn; + UnitCell *out = cell_new(); + + cell_get_cartesian(in, &a.u, &a.v, &a.w, + &b.u, &b.v, &b.w, + &c.u, &c.v, &c.w); + + an = quat_rot(a, quat); + bn = quat_rot(b, quat); + cn = quat_rot(c, quat); + + cell_set_cartesian(out, an.u, an.v, an.w, + bn.u, bn.v, bn.w, + cn.u, cn.v, cn.w); + + return out; +} + + void cell_print(UnitCell *cell) { double asx, asy, asz; @@ -16,6 +16,8 @@ #include <config.h> #endif +#include "utils.h" + /* A 3D vector in reciprocal space */ struct rvec { @@ -73,6 +75,8 @@ extern const char *cell_get_pointgroup(UnitCell *cell); extern double resolution(UnitCell *cell, signed int h, signed int k, signed int l); +extern UnitCell *cell_rotate(UnitCell *in, struct quaternion quat); + extern void cell_print(UnitCell *cell); extern UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose, diff --git a/src/cubeit.c b/src/cubeit.c index b613a3fa..a47a8893 100644 --- a/src/cubeit.c +++ b/src/cubeit.c @@ -220,12 +220,6 @@ static void sum_image(void *pg, int cookie) image.n_cpeaks = 0; image.det = pargs->det; - /* View head-on (unit cell is tilted) */ - image.orientation.w = 1.0; - image.orientation.x = 0.0; - image.orientation.y = 0.0; - image.orientation.z = 0.0; - STATUS("Processing '%s'\n", apargs->filename); hdfile = hdfile_open(apargs->filename); diff --git a/src/detector.c b/src/detector.c index fa3208a6..da423235 100644 --- a/src/detector.c +++ b/src/detector.c @@ -59,7 +59,7 @@ struct rvec get_q(struct image *image, double xs, double ys, q.v = k * sin(twotheta)*sin(az); q.w = k * (cos(twotheta) - 1.0); - return quat_rot(q, image->orientation); + return q; } diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c index bbed9a9b..6e73a52c 100644 --- a/src/diffraction-gpu.c +++ b/src/diffraction-gpu.c @@ -140,12 +140,6 @@ void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, khigh = 1.0/(image->lambda*(1.0 - image->beam->bandwidth/2.0)); bwstep = (khigh-klow) / BWSAMPLING; - /* Orientation */ - orientation.s[0] = image->orientation.w; - orientation.s[1] = image->orientation.x; - orientation.s[2] = image->orientation.y; - orientation.s[3] = image->orientation.z; - ncells.s[0] = na; ncells.s[1] = nb; ncells.s[2] = nc; diff --git a/src/facetron.c b/src/facetron.c index 02de26f5..53fb00f2 100644 --- a/src/facetron.c +++ b/src/facetron.c @@ -412,10 +412,6 @@ int main(int argc, char *argv[]) images[i].filename = fnamereal; images[i].div = beam->divergence; images[i].bw = beam->bandwidth; - images[i].orientation.w = 1.0; - images[i].orientation.x = 0.0; - images[i].orientation.y = 0.0; - images[i].orientation.z = 0.0; images[i].det = det; images[i].beam = beam; diff --git a/src/image.h b/src/image.h index 76e986ea..6b09dfc4 100644 --- a/src/image.h +++ b/src/image.h @@ -92,7 +92,6 @@ struct image { * handling this image */ /* Information about the crystal */ - struct quaternion orientation; double m; /* Mosaicity in radians */ diff --git a/src/indexamajig.c b/src/indexamajig.c index 05a91683..984c1e45 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -217,12 +217,6 @@ static struct image *get_simage(struct image *template, int alternate) image->f0_available = 0; image->f0 = 1.0; - /* View head-on (unit cell is tilted) */ - image->orientation.w = 1.0; - image->orientation.x = 0.0; - image->orientation.y = 0.0; - image->orientation.z = 0.0; - /* Detector geometry for the simulation * - not necessarily the same as the original. */ image->width = 1024; @@ -329,12 +323,6 @@ static void process_image(void *pp, int cookie) image.n_cpeaks = 0; image.det = pargs->static_args.det; - /* View head-on (unit cell is tilted) */ - image.orientation.w = 1.0; - image.orientation.x = 0.0; - image.orientation.y = 0.0; - image.orientation.z = 0.0; - STATUS("Processing '%s'\n", image.filename); pargs->sane = 0; diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 4531c85b..3c1afe07 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -201,7 +201,8 @@ int main(int argc, char *argv[]) int number = 1; /* Number used for filename of image */ int n_images = 1; /* Generate one image by default */ int done = 0; - UnitCell *cell; + UnitCell *input_cell; + struct quaternion orientation; /* Long options */ const struct option longopts[] = { @@ -384,10 +385,14 @@ int main(int argc, char *argv[]) image.width = image.det->max_x + 1; image.height = image.det->max_y + 1; image.lambda = ph_en_to_lambda(eV_to_J(image.beam->photon_energy)); - cell = load_cell_from_pdb(filename); - if ( cell == NULL ) { + + /* Load unit cell */ + input_cell = load_cell_from_pdb(filename); + if ( input_cell == NULL ) { exit(1); } + + /* Initialise stuff */ image.filename = NULL; image.features = NULL; image.flags = NULL; @@ -403,6 +408,7 @@ int main(int argc, char *argv[]) int na, nb, nc; double a, b, c, d; + UnitCell *cell; //na = 8*random()/RAND_MAX + 4; //nb = 8*random()/RAND_MAX + 4; @@ -413,20 +419,22 @@ int main(int argc, char *argv[]) /* Read quaternion from stdin */ if ( config_randomquat ) { - image.orientation = random_quaternion(); + orientation = random_quaternion(); } else { - image.orientation = read_quaternion(); + orientation = read_quaternion(); } STATUS("Orientation is %5.3f %5.3f %5.3f %5.3f\n", - image.orientation.w, image.orientation.x, - image.orientation.y, image.orientation.z); + orientation.w, orientation.x, + orientation.y, orientation.z); - if ( !quaternion_valid(image.orientation) ) { + if ( !quaternion_valid(orientation) ) { ERROR("Orientation modulus is not zero!\n"); return 1; } + cell = cell_rotate(input_cell, orientation); + /* Ensure no residual information */ image.data = NULL; image.twotheta = NULL; @@ -500,6 +508,7 @@ int main(int argc, char *argv[]) /* Clean up */ free(image.data); free(image.twotheta); + cell_free(cell); skip: ndone++; @@ -516,7 +525,7 @@ skip: free(image.det); free(image.beam); free(powder); - cell_free(cell); + cell_free(input_cell); free(intensities); free(outfile); free(filename); diff --git a/src/peaks.c b/src/peaks.c index e7ec9c9e..7c91f817 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -668,9 +668,6 @@ static void output_header(FILE *ofh, UnitCell *cell, struct image *image) double a, b, c, al, be, ga; fprintf(ofh, "Reflections from indexing in %s\n", image->filename); - fprintf(ofh, "Orientation (wxyz): %7.5f %7.5f %7.5f %7.5f\n", - image->orientation.w, image->orientation.x, - image->orientation.y, image->orientation.z); cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga); fprintf(ofh, "Cell parameters %7.5f %7.5f %7.5f nm, %7.5f %7.5f %7.5f deg\n", diff --git a/src/reintegrate.c b/src/reintegrate.c index 220cad26..906d1859 100644 --- a/src/reintegrate.c +++ b/src/reintegrate.c @@ -112,12 +112,6 @@ static void process_image(void *pg, int cookie) image.n_cpeaks = 0; image.det = pargs->det; - /* View head-on (unit cell is tilted) */ - image.orientation.w = 1.0; - image.orientation.x = 0.0; - image.orientation.y = 0.0; - image.orientation.z = 0.0; - STATUS("Processing '%s'\n", apargs->filename); hdfile = hdfile_open(apargs->filename); |