aboutsummaryrefslogtreecommitdiff
path: root/src/control.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/control.c')
-rw-r--r--src/control.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/control.c b/src/control.c
index ac3de0b..97ad34c 100644
--- a/src/control.c
+++ b/src/control.c
@@ -25,6 +25,7 @@ int control_add_image(ControlContext *ctx, uint16_t *image, int width, int heigh
ctx->images[ctx->n_images].fmode = ctx->fmode;
ctx->images[ctx->n_images].x_centre = ctx->x_centre;
ctx->images[ctx->n_images].y_centre = ctx->y_centre;
+ ctx->images[ctx->n_images].slop = 0.0;
if ( ctx->fmode == FORMULATION_PIXELSIZE ) {
ctx->images[ctx->n_images].pixel_size = ctx->pixel_size;
@@ -56,3 +57,49 @@ ControlContext *control_ctx_new() {
}
+/* Return the minimum (most negative) tilt angle used */
+double control_min_tilt(ControlContext *ctx) {
+
+ int i;
+ double min = 360;
+
+ for ( i=0; i<ctx->n_images; i++ ) {
+ if ( ctx->images[i].tilt < min ) min = ctx->images[i].tilt;
+ }
+
+ return min;
+
+}
+
+/* Return the maximum (most negative) tilt angle used */
+double control_max_tilt(ControlContext *ctx) {
+
+ int i;
+ double max = -360;
+
+ for ( i=0; i<ctx->n_images; i++ ) {
+ if ( ctx->images[i].tilt > max ) max = ctx->images[i].tilt;
+ }
+
+ return max;
+
+}
+
+/* Return a reference to the image record with tilt closest to the given value */
+ImageRecord *control_image_nearest_tilt(ControlContext *ctx, double tilt) {
+
+ int i;
+ double dev = 360;
+ ImageRecord *im = NULL;
+
+ for ( i=0; i<ctx->n_images; i++ ) {
+ if ( ctx->images[i].tilt - tilt < dev ) {
+ dev = ctx->images[i].tilt - tilt;
+ im = &ctx->images[i];
+ }
+ }
+
+ return im;
+
+}
+