From d2f89b05a5c6d002135c6b5898ca5540cfcec7ea Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 22 Feb 2019 11:42:29 +0100 Subject: Initial centering determination --- libcrystfel/src/cell.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c index 5eb13349..a26e26a6 100644 --- a/libcrystfel/src/cell.c +++ b/libcrystfel/src/cell.c @@ -46,6 +46,7 @@ #include "utils.h" #include "image.h" #include "integer_matrix.h" +#include "rational.h" /** @@ -687,6 +688,31 @@ UnitCell *cell_transform_gsl_reciprocal(UnitCell *in, gsl_matrix *m) } +static char determine_centering(IntegerMatrix *m, char cen) +{ + Rational c[3]; + Rational nc[3]; + + c[0] = rtnl(1, 2); + c[1] = rtnl(1, 2); + c[2] = rtnl_zero(); + intmat_rationalvec_mult(m, c, nc); + STATUS("%s,%s,%s -> %s,%s,%s\n", + rtnl_format(c[0]), rtnl_format(c[1]), rtnl_format(c[2]), + rtnl_format(nc[0]), rtnl_format(nc[1]), rtnl_format(nc[2])); + + c[0] = rtnl_zero(); + c[1] = rtnl_zero(); + c[2] = rtnl_zero(); + intmat_solve_rational(m, nc, c); + STATUS("%s,%s,%s <- %s,%s,%s\n", + rtnl_format(c[0]), rtnl_format(c[1]), rtnl_format(c[2]), + rtnl_format(nc[0]), rtnl_format(nc[1]), rtnl_format(nc[2])); + + return 'A'; +} + + /** * cell_transform_rational: * @cell: A %UnitCell. @@ -701,6 +727,7 @@ UnitCell *cell_transform_rational(UnitCell *cell, RationalMatrix *m) { UnitCell *out; gsl_matrix *tm; + char ncen; if ( m == NULL ) return NULL; @@ -720,10 +747,16 @@ UnitCell *cell_transform_rational(UnitCell *cell, RationalMatrix *m) gsl_matrix_set(tm, 2, 2, rtnl_as_double(rtnl_mtx_get(m, 2, 2))); out = cell_transform_gsl_direct(cell, tm); + gsl_matrix_free(tm); - /* FIXME: Update centering, unique axis, lattice type */ + ncen = determine_centering(m, cell_get_centering(cell)); + if ( ncen == '*' ) { + cell_free(out); + return NULL; + } + cell_set_centering(out, ncen); - gsl_matrix_free(tm); + /* FIXME: Update unique axis, lattice type */ return out; } -- cgit v1.2.3