diff options
author | Alexandra Tolstikova <alexandra.tolstikova@desy.de> | 2015-02-11 16:18:18 +0100 |
---|---|---|
committer | Alexandra Tolstikova <alexandra.tolstikova@desy.de> | 2015-02-11 16:18:18 +0100 |
commit | 21b67e8dc422ee5f437bf2e31c5616982fc41c98 (patch) | |
tree | 4df32d02e3ad6f5cb9c6b35256d30fa6c7309627 /libcrystfel/src/cell-utils.c | |
parent | a095923e5ee59201c43e3722903bae8745e40bf3 (diff) |
Move cell_get_volume from asdf.c to cell_utils.c
Diffstat (limited to 'libcrystfel/src/cell-utils.c')
-rw-r--r-- | libcrystfel/src/cell-utils.c | 28 |
1 files changed, 28 insertions, 0 deletions
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; +} |