diff options
author | Thomas White <taw@physics.org> | 2012-09-27 12:28:57 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-10-02 15:02:12 +0200 |
commit | 487f375b726fd555ff0c7eab40499201fc2e1d7d (patch) | |
tree | 28721dbbada5e27e770a60fbae2cb45d0ec1f8f1 /tests/transformation_check.c | |
parent | 7b31c8f41732b6ca5402afd8fe6cb4d6e185bc48 (diff) |
Finishing tweaks for uncentering stuff
Today, I have mostly been having my life made difficult by the PDB's invention of "H centering".
Diffstat (limited to 'tests/transformation_check.c')
-rw-r--r-- | tests/transformation_check.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/transformation_check.c b/tests/transformation_check.c index 80324795..7d25aa04 100644 --- a/tests/transformation_check.c +++ b/tests/transformation_check.c @@ -73,6 +73,39 @@ static int check_transformation(UnitCell *cell, UnitCellTransformation *tfn) } +static int check_identity(UnitCell *cell, UnitCellTransformation *tfn) +{ + UnitCell *cnew; + double a[9], b[9]; + int i; + int fail = 0; + + cnew = cell_transform(cell, tfn); + + cell_get_cartesian(cell, &a[0], &a[1], &a[2], + &a[3], &a[4], &a[5], + &a[6], &a[7], &a[8]); + cell_get_cartesian(cnew, &b[0], &b[1], &b[2], + &b[3], &b[4], &b[5], + &b[6], &b[7], &b[8]); + for ( i=0; i<9; i++ ) { + if ( !within_tolerance(a[i], b[i], 0.1) ) { + fail = 1; + STATUS("%e %e\n", a[i], b[i]); + } + } + + if ( fail ) { + ERROR("Original cell not recovered after transformation:\n"); + cell_print(cell); + tfn_print(tfn); + cell_print(cnew); + } + + return fail; +} + + int main(int argc, char *argv[]) { int fail = 0; @@ -125,6 +158,18 @@ int main(int argc, char *argv[]) fail += check_transformation(cell, tfn); tfn_free(tfn); + /* Identity in two parts */ + tfn = tfn_identity(); + if ( tfn == NULL ) return 1; + tfn_combine(tfn, tfn_vector(0,0,1), + tfn_vector(0,1,0), + tfn_vector(-1,0,0)); + tfn_combine(tfn, tfn_vector(0,0,-1), + tfn_vector(0,1,0), + tfn_vector(1,0,0)); + fail += check_identity(cell, tfn); + tfn_free(tfn); + cell_free(cell); return fail; |