From 21b67e8dc422ee5f437bf2e31c5616982fc41c98 Mon Sep 17 00:00:00 2001 From: Alexandra Tolstikova Date: Wed, 11 Feb 2015 16:18:18 +0100 Subject: Move cell_get_volume from asdf.c to cell_utils.c --- libcrystfel/src/asdf.c | 27 --------------------------- libcrystfel/src/cell-utils.c | 28 ++++++++++++++++++++++++++++ libcrystfel/src/cell-utils.h | 2 ++ 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c index 28afe82d..0b890ef8 100644 --- a/libcrystfel/src/asdf.c +++ b/libcrystfel/src/asdf.c @@ -995,33 +995,6 @@ static int index_refls(gsl_vector **reflections, int N_reflections, } -double cell_get_volume(UnitCell *cell) -{ - double asx, asy, asz; - double bsx, bsy, bsz; - double csx, csy, csz; - struct rvec aCb; - double volume; - - if ( cell_get_reciprocal(cell, &asx, &asy, &asz, - &bsx, &bsy, &bsz, - &csx, &csy, &csz) ) { - ERROR("Couldn't get cell cartesian.\n"); - return 0; - } - - /* "a" cross "b" */ - aCb.u = asy*bsz - asz*bsy; - aCb.v = - (asx*bsz - asz*bsx); - aCb.w = asx*bsy - asy*bsx; - - /* "a cross b" dot "c" */ - volume = (aCb.u*csx + aCb.v*csy + aCb.w*csz)/1e30; - - return 1/volume; -} - - int run_asdf(struct image *image, IndexingPrivate *ipriv) { int i, j; diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c index 95e7353e..5fc885e5 100644 --- a/libcrystfel/src/cell-utils.c +++ b/libcrystfel/src/cell-utils.c @@ -1567,3 +1567,31 @@ int forbidden_reflection(UnitCell *cell, return 0; } + + +/* Returns cell volume in A^3 */ +double cell_get_volume(UnitCell *cell) +{ + double asx, asy, asz; + double bsx, bsy, bsz; + double csx, csy, csz; + struct rvec aCb; + double rec_volume; + + if ( cell_get_reciprocal(cell, &asx, &asy, &asz, + &bsx, &bsy, &bsz, + &csx, &csy, &csz) ) { + ERROR("Couldn't get reciprocal cell.\n"); + return 0; + } + + /* "a" cross "b" */ + aCb.u = asy*bsz - asz*bsy; + aCb.v = - (asx*bsz - asz*bsx); + aCb.w = asx*bsy - asy*bsx; + + /* "a cross b" dot "c" */ + rec_volume = (aCb.u*csx + aCb.v*csy + aCb.w*csz)/1e30; + + return 1/rec_volume; +} diff --git a/libcrystfel/src/cell-utils.h b/libcrystfel/src/cell-utils.h index 0b900096..98bc667c 100644 --- a/libcrystfel/src/cell-utils.h +++ b/libcrystfel/src/cell-utils.h @@ -74,6 +74,8 @@ extern LatticeType lattice_from_str(const char *s); extern int forbidden_reflection(UnitCell *cell, signed int h, signed int k, signed int l); +extern double cell_get_volume(UnitCell *cell); + #ifdef __cplusplus } #endif -- cgit v1.2.3