diff options
author | Thomas White <taw@physics.org> | 2024-10-16 16:17:20 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-10-16 16:58:49 +0200 |
commit | 500cd51bef443aa69d9d09f046beadeff2872c08 (patch) | |
tree | 29353a9f651b5381484b6611e3d3ef6ae90efd58 /libcrystfel/src/indexers/smallcell.c | |
parent | 113a300292bbffb6c829b1da182328615c07e3b3 (diff) |
smallcell: Move d_2 calculation to separate function
Diffstat (limited to 'libcrystfel/src/indexers/smallcell.c')
-rw-r--r-- | libcrystfel/src/indexers/smallcell.c | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/libcrystfel/src/indexers/smallcell.c b/libcrystfel/src/indexers/smallcell.c index 242dfb0b..966519a8 100644 --- a/libcrystfel/src/indexers/smallcell.c +++ b/libcrystfel/src/indexers/smallcell.c @@ -386,6 +386,15 @@ static void BK(struct Nodelist *R, } +static double calc_d2(struct PeakInfo a, struct PeakInfo b, struct g_matrix g9) +{ + /* d_2 = sqrt(Transpose(MI_b - MI_a).G*.(MI_b - MI_a)) */ + return sqrt((b.h - a.h) * (g9.A * (b.h - a.h) + g9.D * (b.k - a.k) + g9.G * (b.l - a.l)) + + (b.k - a.k) * (g9.B * (b.h - a.h) + g9.E * (b.k - a.k) + g9.H * (b.l - a.l)) + + (b.l - a.l) * (g9.C * (b.h - a.h) + g9.F * (b.k - a.k) + g9.J * (b.l - a.l))); +} + + int smallcell_index(struct image *image, void *mpriv) { struct smallcell_private *priv = (struct smallcell_private *)mpriv; @@ -484,8 +493,6 @@ int smallcell_index(struct image *image, void *mpriv) /* Now to connect the nodes using calculated and measured reciprocal distance */ - - struct g_matrix g9 = priv->g9; double dtol = DIFF_TOL; int n_connected_nodes = 0; int j; @@ -493,9 +500,6 @@ int smallcell_index(struct image *image, void *mpriv) /* Loop through peak numbers */ for ( j=0; j<num_peak_infos; j++ ) { - int node_a_h = peak_infos[j].h; - int node_a_k = peak_infos[j].k; - int node_a_l = peak_infos[j].l; int y; /* Loop through the rest of the peak infos */ @@ -512,33 +516,7 @@ int smallcell_index(struct image *image, void *mpriv) peak_infos[j].z - peak_infos[y].z); /* Predicted d_2 */ - int node_b_h = peak_infos[y].h; - int node_b_k = peak_infos[y].k; - int node_b_l = peak_infos[y].l; - - /* d_2 = sqrt(Transpose(MI_b - MI_a).G*.(MI_b - MI_a)) */ - double d_2 = - sqrt((node_b_h - - node_a_h) * (g9.A * (node_b_h - - node_a_h) + - g9.D * (node_b_k - - node_a_k) + - g9.G * (node_b_l - node_a_l)) - + (node_b_k - - node_a_k) * (g9.B * (node_b_h - - node_a_h) + - g9.E * (node_b_k - - node_a_k) + - g9.H * (node_b_l - - node_a_l)) - + (node_b_l - - node_a_l) * (g9.C * (node_b_h - - node_a_h) + - g9.F * (node_b_k - - node_a_k) + - g9.J * (node_b_l - - node_a_l))); - + double d_2 = calc_d2(peak_infos[j], peak_infos[y], priv->g9); double diff = fabs(d_2 - d_1); |