aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/cell.c26
-rw-r--r--libcrystfel/src/cell.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c
index e7c9dace..11aa83fa 100644
--- a/libcrystfel/src/cell.c
+++ b/libcrystfel/src/cell.c
@@ -784,6 +784,32 @@ UnitCellTransformation *tfn_identity()
}
+
+/**
+ * tfn_from_intmat:
+ * @m: An %IntegerMatrix
+ *
+ * Returns: A %UnitCellTransformation corresponding to @m.
+ *
+ */
+UnitCellTransformation *tfn_from_intmat(IntegerMatrix *m)
+{
+ UnitCellTransformation *tfn;
+ int i, j;
+
+ tfn = tfn_identity();
+ if ( tfn == NULL ) return NULL;
+
+ for ( i=0; i<3; i++ ) {
+ for ( j=0; j<3; j++ ) {
+ gsl_matrix_set(tfn->m, i, j, intmat_get(m, i, j));
+ }
+ }
+
+ return tfn;
+}
+
+
/**
* tfn_combine:
* @t: A %UnitCellTransformation
diff --git a/libcrystfel/src/cell.h b/libcrystfel/src/cell.h
index c7b8f8d6..cde25b07 100644
--- a/libcrystfel/src/cell.h
+++ b/libcrystfel/src/cell.h
@@ -38,6 +38,7 @@
#endif
#include "utils.h"
+#include "integer_matrix.h"
/* A 3D vector in reciprocal space.
* Note: Heavily abused to serve as a real space vector as well */
@@ -141,6 +142,7 @@ extern UnitCell *cell_transform_inverse(UnitCell *cell,
UnitCellTransformation *t);
extern UnitCellTransformation *tfn_identity(void);
+extern UnitCellTransformation *tfn_from_intmat(IntegerMatrix *m);
extern void tfn_combine(UnitCellTransformation *t,
double *na, double *nb, double *nc);
extern void tfn_print(UnitCellTransformation *t);