diff options
author | Thomas White <taw@physics.org> | 2010-10-13 10:26:01 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:03 +0100 |
commit | 8c35be50e8380709afe5f84e003f86c3e31ba578 (patch) | |
tree | 39cea74f03d12360f81142e8b5b3e8545c7cff62 /src/cell.c | |
parent | d9b6e615f7d7e2acf5506f82c7dece4a40f3f6cf (diff) |
Matched cell must also be right-handed!
Diffstat (limited to 'src/cell.c')
-rw-r--r-- | src/cell.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -532,6 +532,24 @@ static int within_tolerance(double a, double b, double percent) } +static int right_handed(struct rvec a, struct rvec b, struct rvec c) +{ + struct rvec aCb; + double aCb_dot_c; + + /* "a" cross "b" */ + aCb.u = a.v*b.w - a.w*b.v; + aCb.v = - (a.u*b.w - a.w*b.u); + aCb.w = a.u*b.v - a.v*b.u; + + /* "a cross b" dot "c" */ + aCb_dot_c = aCb.u*c.u + aCb.v*c.v + aCb.w*c.w; + + if ( aCb_dot_c > 0.0 ) return 1; + return 0; +} + + struct cvec { struct rvec vec; float na; @@ -707,6 +725,10 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose) /* ... it should be angle 0 ... */ if ( fabs(ang - angles[0]) > angtol ) continue; + /* Unit cell must be right-handed */ + if ( !right_handed(cand[0][i].vec, cand[1][j].vec, + cand[2][k].vec) ) continue; + fom3 = fom2 + fabs(ang - angles[0]); fom3 += LWEIGHT * (cand[0][i].fom + cand[1][j].fom + cand[2][k].fom); |