aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/cell-utils.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-08-14 14:04:32 +0200
committerThomas White <taw@physics.org>2019-08-16 10:26:58 +0200
commitaf115ec0a455929352fef516c35d2b77cd283e9d (patch)
tree5c424b7c44426287ccb86c15adbe951fc0d3b922 /libcrystfel/src/cell-utils.c
parent2676cb9d314bb0dbe128738e8ced25de75129802 (diff)
cell_volume: Give answer in m^3, not m^3
Diffstat (limited to 'libcrystfel/src/cell-utils.c')
-rw-r--r--libcrystfel/src/cell-utils.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c
index 59e98775..82b42b98 100644
--- a/libcrystfel/src/cell-utils.c
+++ b/libcrystfel/src/cell-utils.c
@@ -1637,32 +1637,29 @@ int forbidden_reflection(UnitCell *cell,
/**
- * \returns cell volume in A^3
+ * \returns cell volume in m^3
*/
double cell_get_volume(UnitCell *cell)
{
- double asx, asy, asz;
- double bsx, bsy, bsz;
- double csx, csy, csz;
+ double ax, ay, az;
+ double bx, by, bz;
+ double cx, cy, cz;
struct rvec aCb;
- double rec_volume;
- if ( cell_get_reciprocal(cell, &asx, &asy, &asz,
- &bsx, &bsy, &bsz,
- &csx, &csy, &csz) ) {
+ if ( cell_get_cartesian(cell, &ax, &ay, &az,
+ &bx, &by, &bz,
+ &cx, &cy, &cz) ) {
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;
+ aCb.u = ay*bz - az*by;
+ aCb.v = - (ax*bz - az*bx);
+ aCb.w = ax*by - ay*bx;
/* "a cross b" dot "c" */
- rec_volume = (aCb.u*csx + aCb.v*csy + aCb.w*csz)/1e30;
-
- return 1/rec_volume;
+ return (aCb.u*cx + aCb.v*cy + aCb.w*cz);
}