Commit 1b4fa114 authored by Thomas White's avatar Thomas White
Browse files

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".
parent fcde5d4f
......@@ -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,
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -92,7 +92,6 @@ struct image {
* handling this image */
/* Information about the crystal */
struct quaternion orientation;
double m; /* Mosaicity in radians */
......
......@@ -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;
......
......@@ -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);
......
......@@ -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",
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment