From 1ed23746f6d27f648e3a5f96bf499823069fd171 Mon Sep 17 00:00:00 2001 From: taw27 Date: Thu, 27 Sep 2007 22:12:26 +0000 Subject: Fix really stupid obvious bugs git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@134 bf6ca9ba-c028-0410-8290-897cf20841d1 --- src/control.c | 7 ++++--- src/displaywindow.c | 4 +++- src/ipr.c | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/control.c b/src/control.c index 97ad34c..270be6f 100644 --- a/src/control.c +++ b/src/control.c @@ -11,6 +11,7 @@ #include #include +#include #include "control.h" @@ -71,7 +72,7 @@ double control_min_tilt(ControlContext *ctx) { } -/* Return the maximum (most negative) tilt angle used */ +/* Return the maximum (most positive) tilt angle used */ double control_max_tilt(ControlContext *ctx) { int i; @@ -93,8 +94,8 @@ ImageRecord *control_image_nearest_tilt(ControlContext *ctx, double tilt) { ImageRecord *im = NULL; for ( i=0; in_images; i++ ) { - if ( ctx->images[i].tilt - tilt < dev ) { - dev = ctx->images[i].tilt - tilt; + if ( fabs(ctx->images[i].tilt - tilt) < dev ) { + dev = fabs(ctx->images[i].tilt - tilt); im = &ctx->images[i]; } } diff --git a/src/displaywindow.c b/src/displaywindow.c index 6a3adfe..eedad54 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -484,6 +484,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glEnd(); /* x, y, z pointers */ +#if 0 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); DRAW_SHORT_POINTER @@ -498,7 +499,8 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glRotatef(-90.0, 0.0, 1.0, 0.0); DRAW_SHORT_POINTER glPopMatrix(); - +#endif + /* Tilt axis */ glPushMatrix(); /* Images rotate clockwise by omega to put tilt axis at +x, diff --git a/src/ipr.c b/src/ipr.c index 9324426..47b57e2 100644 --- a/src/ipr.c +++ b/src/ipr.c @@ -48,7 +48,8 @@ static Basis *ipr_choose_random_basis(ControlContext *ctx) { double x, y, z; Reflection *centre; - /* Locate the 'plane' in the middle of the "wedge" */ + /* Locate the 'plane' in the middle of the "wedge". + * This whole procedure assumes there is just one tilt axis. */ tilt_min = control_min_tilt(ctx); tilt_max = control_max_tilt(ctx); tilt_mid = tilt_min + (tilt_max-tilt_min)/2; @@ -56,12 +57,11 @@ static Basis *ipr_choose_random_basis(ControlContext *ctx) { /* Apply the last two steps of the mapping transform to get the direction from the origin * towards the middle of the wedge */ - printf("tilt_mid=%f deg, tilt=%f deg\n", tilt_mid, imagerecord->tilt); x_temp = 0.0; - y_temp = cos(imagerecord->tilt); - z_temp = -sin(imagerecord->tilt); - x = x_temp*cos(-imagerecord->omega) + y_temp*sin(-imagerecord->omega); - y = -x_temp*sin(-imagerecord->omega) + y_temp*cos(-imagerecord->omega); + y_temp = cos(deg2rad(imagerecord->tilt)); + z_temp = -sin(deg2rad(imagerecord->tilt)); + x = x_temp*cos(-deg2rad(imagerecord->omega)) + y_temp*sin(-deg2rad(imagerecord->omega)); + y = -x_temp*sin(-deg2rad(imagerecord->omega)) + y_temp*cos(-deg2rad(imagerecord->omega)); z = z_temp; /* Find the point in the middle of the "wedge" */ @@ -69,12 +69,11 @@ static Basis *ipr_choose_random_basis(ControlContext *ctx) { x *= scale; y *= scale; z *= scale; - reflection_add(ctx->reflectionctx, x, y, z, 1.0, REFLECTION_VECTOR_MARKER_1); - reflection_add(ctx->reflectionctx, x_temp*scale, y_temp*scale, z_temp*scale, 1.0, REFLECTION_VECTOR_MARKER_3); + reflection_add(ctx->reflectionctx, x, y, z, 1.0, REFLECTION_VECTOR_MARKER_2); centre = reflection_find_nearest(ctx->reflectionctx, x, y, z); if ( !centre ) return NULL; - reflection_add(ctx->reflectionctx, centre->x, centre->y, centre->z, 1.0, REFLECTION_VECTOR_MARKER_2); + reflection_add(ctx->reflectionctx, centre->x, centre->y, centre->z, 1.0, REFLECTION_MARKER); basis = malloc(sizeof(Basis)); @@ -120,6 +119,8 @@ static double ipr_efom(ReflectionContext *rctx, Basis *basis) { if ( h == 1.0 ) h = 0.0; if ( k == 1.0 ) k = 0.0; if ( l == 1.0 ) l = 0.0; + + /* Define "approximately" here. Circle in basis space becomes an ellipsoid in reciprocal space */ if ( h*h + k*k + l*l <= 0.1*0.1*0.1 ) n_indexed++; n_counted++; -- cgit v1.2.3