From d91e23905783bdb36c7d1c982a1cf890ae5ce1fd Mon Sep 17 00:00:00 2001 From: taw27 Date: Tue, 4 Sep 2007 13:46:07 +0000 Subject: Working reprojection git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@109 bf6ca9ba-c028-0410-8290-897cf20841d1 --- src/displaywindow.c | 8 ++++---- src/ipr.c | 7 +++---- src/reproject.c | 17 ++++++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/displaywindow.c b/src/displaywindow.c index 9afa2ad..31889df 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -287,8 +287,8 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { GLfloat blue_spec[] = { 0.0, 0.0, 1.0, 1.0 }; GLfloat red[] = { 1.0, 0.0, 0.0, 1.0 }; GLfloat yellow[] = { 1.0, 1.0, 0.0, 1.0 }; - GLfloat yellow_glass[] = { 1.0, 1.0, 0.0, 000.1 }; - GLfloat yellow_glass_spec[] = { 1.0, 1.0, 0.0, 1.0 }; + GLfloat glass[] = { 0.2, 0.0, 0.8, 000.1 }; + GLfloat glass_spec[] = { 0.8, 0.8, 0.8, 1.0 }; Reflection *reflection; GLUquadricObj *quadric; int i; @@ -548,8 +548,8 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { /* Zero plane */ glBegin(GL_QUADS); - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, yellow_glass); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, yellow_glass_spec); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, glass); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, glass_spec); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50.0); glVertex3f(50, 50, 0.0); glVertex3f(50, -50, 0.0); diff --git a/src/ipr.c b/src/ipr.c index 813e060..a6af8ed 100644 --- a/src/ipr.c +++ b/src/ipr.c @@ -205,9 +205,9 @@ static ReflectionContext *ipr_generate(ControlContext *ctx, Basis *basis) { } ordered = reflection_init(); - basis->a.x = 1.842e9; basis->a.y = 0.0; basis->a.z = 0.0; - basis->b.x = 0.0; basis->b.y = 1.842e9; basis->b.z = 0.0; - basis->c.x = 0.0; basis->c.y = 0.0; basis->c.z = 1.842e9; +// basis->a.x = 1.842e9; basis->a.y = 0.0; basis->a.z = 0.0; +// basis->b.x = 0.0; basis->b.y = 1.842e9; basis->b.z = 0.0; +// basis->c.x = 0.0; basis->c.y = 0.0; basis->c.z = 1.842e9; for ( h=-30; h<=30; h++ ) { for ( k=-30; k<=30; k++ ) { for ( l=-30; l<=30; l++ ) { @@ -263,7 +263,6 @@ int ipr_refine(ControlContext *ctx) { /* Select an image */ i = ipr_random_image(ctx); - i = 58; /* Temporary! */ cur = imagedisplay_open(ctx->images[i], "Current Image", IMAGEDISPLAY_SHOW_CENTRE | IMAGEDISPLAY_SHOW_TILT_AXIS); refl = reproject_get_reflections(ctx->images[i], &n, lat, ctx); diff --git a/src/reproject.c b/src/reproject.c index 5594451..efd32c9 100644 --- a/src/reproject.c +++ b/src/reproject.c @@ -40,7 +40,7 @@ ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, Reflect double nx, ny, nz; double xt, yt, zt; double a, b, c; - double s1, s2, s; + double A1, A2, s1, s2, s; /* Get the coordinates of the reciprocal lattice point */ xl = reflection->x; @@ -49,18 +49,21 @@ ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, Reflect /* Now calculate the (normalised) incident electron wavevector */ xt = 0; - yt = sin(tilt); - zt = cos(tilt); + yt = sin(tilt); + zt = cos(tilt); nx = xt*cos(omega) + yt*-sin(omega); ny = xt*sin(omega) + yt*cos(omega); nz = zt; /* Next, solve the relrod equation to calculate the excitation error */ a = 1.0; - b = 2.0*(xl*nx + yl*ny + zl*nz - nz/image.lambda); - c = xl*xl + yl*yl + zl*zl - 2.0*zl/image.lambda; - s1 = (-b + sqrt(b*b-4.0*a*c))/(2.0*a); - s2 = (-b - sqrt(b*b-4.0*a*c))/(2.0*a); + b = -2.0*(xl*nx + yl*ny + zl*nz); + c = xl*xl + yl*yl + zl*zl - 1.0/(image.lambda*image.lambda); + A1 = (-b + sqrt(b*b-4.0*a*c))/(2.0*a); + A2 = (-b - sqrt(b*b-4.0*a*c))/(2.0*a); + s1 = 1.0/image.lambda - A1; + s2 = 1.0/image.lambda - A2; + if ( fabs(s1) < fabs(s2) ) s = s1; else s = s2; /* Skip this reflection if s is large */ -- cgit v1.2.3