aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/cell-utils.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-06-18 14:27:41 +0200
committerThomas White <taw@physics.org>2015-06-18 14:27:41 +0200
commit8b21e8706963a8f327759b24377e7dff2fff60db (patch)
tree397aefc7cb57005fc99d61da609834f331746265 /libcrystfel/src/cell-utils.c
parentedf2ad46f4c0f403b90d3058018a295baa9d0753 (diff)
parent091e3378a95edab85a6c655629df4270fb041b04 (diff)
Merge branch 'tolstikova/dirax'
Conflicts: libcrystfel/src/index.h
Diffstat (limited to 'libcrystfel/src/cell-utils.c')
-rw-r--r--libcrystfel/src/cell-utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c
index 9676aade..75419c99 100644
--- a/libcrystfel/src/cell-utils.c
+++ b/libcrystfel/src/cell-utils.c
@@ -1576,3 +1576,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;
+}