aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-04-22 15:46:14 +0200
committerThomas White <taw@physics.org>2024-04-22 16:26:26 +0200
commit2ec6a17ed01f09733c8d425f8197e533781a8f99 (patch)
tree31ee4d4595b8473579cd4f255543937070e81b09
parent904bfc512e618e45c36a29a6259aeaac0b09906e (diff)
asdf: Don't store cell volume
It's hardly needed for re-use, and invites problems with the volume going out of sync with the vectors. Better just to calculate it when needed.
-rw-r--r--libcrystfel/src/indexers/asdf.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/libcrystfel/src/indexers/asdf.c b/libcrystfel/src/indexers/asdf.c
index 919e570f..6cfd741a 100644
--- a/libcrystfel/src/indexers/asdf.c
+++ b/libcrystfel/src/indexers/asdf.c
@@ -115,7 +115,6 @@ struct asdf_cell {
gsl_vector *reciprocal[3];
int n; // number of fitting reflections
- double volume;
int N_refls; // total number of reflections
int *reflections; // reflections[i] = 1 if reflections fits
@@ -213,8 +212,6 @@ static int asdf_cell_memcpy(struct asdf_cell *dest, struct asdf_cell *src)
gsl_vector_memcpy(dest->reciprocal[i], src->reciprocal[i]);
}
- dest->volume = src->volume;
-
int n = src->N_refls;
dest->n = src->n;
@@ -289,6 +286,25 @@ static int calc_reciprocal(gsl_vector **direct, gsl_vector **reciprocal)
}
+static int asdf_right_handed(struct asdf_cell *cl)
+{
+ double volume;
+ gsl_vector *vc = gsl_vector_alloc(3);
+ cross_product(cl->axes[0], cl->axes[1], &vc);
+ gsl_blas_ddot(vc, cl->axes[2], &volume);
+ gsl_vector_free(vc);
+ return volume > 0.0;
+}
+
+
+static void force_right_handed(struct asdf_cell *cl)
+{
+ if ( !asdf_right_handed(cl) ) {
+ gsl_vector_scale(cl->axes[2], -1);
+ }
+}
+
+
static int compare_doubles(const void *a, const void *b)
{
const double *da = (const double *) a;
@@ -694,12 +710,7 @@ static int reduce_asdf_cell(struct asdf_cell *cl)
if (n > 30) changed = 0;
}
- cross_product(cl->axes[0], cl->axes[1], &vc);
- gsl_blas_ddot(vc, cl->axes[2], &cl->volume);
- if ( cl->volume < 0 ) {
- gsl_vector_scale(cl->axes[2], -1);
- cl->volume *= -1;
- }
+ force_right_handed(cl);
gsl_vector_free(va);
gsl_vector_free(vb);
@@ -760,7 +771,6 @@ static int create_cell(struct tvector tvec1, struct tvector tvec2,
gsl_vector_memcpy(c->axes[1], tvec2.t);
gsl_vector_memcpy(c->axes[2], tvec3.t);
- c->volume = volume;
check_refl_fitting_cell(c, reflections, N_reflections, IndexFit);
if ( c->n < 6 ) return 0;