diff options
author | Thomas White <taw@physics.org> | 2011-09-12 17:31:43 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:37 +0100 |
commit | 1c2e32b7bd576bcb4b249c476373ee697ae92102 (patch) | |
tree | 85d5b587621f7714d203d578bee875e1606a3e1e /src/cell.c | |
parent | 0dc9653457caa13cc1c87833e88afdd7deea6ec5 (diff) |
Check unit cell is sensible
Diffstat (limited to 'src/cell.c')
-rw-r--r-- | src/cell.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -1142,3 +1142,23 @@ UnitCell *rotate_cell(UnitCell *in, double omega, double phi, double rot) return out; } + + +int cell_is_sensible(UnitCell *cell) +{ + double a, b, c, al, be, ga; + + cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga); + if ( al + be + ga >= 2.0*M_PI ) return 0; + if ( al + be - ga >= 2.0*M_PI ) return 0; + if ( al - be + ga >= 2.0*M_PI ) return 0; + if ( - al + be + ga >= 2.0*M_PI ) return 0; + if ( al + be + ga <= 0.0 ) return 0; + if ( al + be - ga <= 0.0 ) return 0; + if ( al - be + ga <= 0.0 ) return 0; + if ( - al + be + ga <= 0.0 ) return 0; + if ( isnan(al) ) return 0; + if ( isnan(be) ) return 0; + if ( isnan(ga) ) return 0; + return 1; +} |