aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-09-27 22:12:26 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-09-27 22:12:26 +0000
commit1ed23746f6d27f648e3a5f96bf499823069fd171 (patch)
treea810520b178e9bd0783f978c42d1b63be875cfc2 /src
parenta7d5360db028fc24547ece8e7a4bc49ecfaa8743 (diff)
Fix really stupid obvious bugs
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@134 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src')
-rw-r--r--src/control.c7
-rw-r--r--src/displaywindow.c4
-rw-r--r--src/ipr.c19
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 <inttypes.h>
#include <stdlib.h>
+#include <math.h>
#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; i<ctx->n_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++;