diff options
author | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-10-31 17:38:50 +0000 |
---|---|---|
committer | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-10-31 17:38:50 +0000 |
commit | 6d379bfdc3b6c48e3f7bc6a6d39ef7c55c1f6b74 (patch) | |
tree | 03cd71dc7979d60aa062382473f73e6cdb90e826 /src | |
parent | d2c4ca0e9358b048946ae9f484474826a278f5ac (diff) |
Arithmetic fixes
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@188 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src')
-rw-r--r-- | src/refine.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/refine.c b/src/refine.c index 01c4bcb..14eba42 100644 --- a/src/refine.c +++ b/src/refine.c @@ -146,21 +146,21 @@ static void refine_fit_image(Basis *cell, ImageRecord *image, ReflectionList *ce } if ( shared & INDEX_A ) { - double w = h / (h+k+l); + double w = abs(h) / (abs(h)+abs(k)+abs(l)); cd.a.x += w*dx / h; cd.a.y += w*dy / h; cd.a.z += w*dz / h; n_a++; } if ( shared & INDEX_B ) { - double w = k / (h+k+l); + double w = abs(k) / (abs(h)+abs(k)+abs(l)); cd.b.x += w*dx / k; cd.b.y += w*dy / k; cd.b.z += w*dz / k; n_b++; } if ( shared & INDEX_C ) { - double w = l / (h+k+l); + double w = abs(l) / (abs(h)+abs(k)+abs(l)); cd.c.x += w*dx / l; cd.c.y += w*dy / l; cd.c.z += w*dz / l; @@ -171,9 +171,15 @@ static void refine_fit_image(Basis *cell, ImageRecord *image, ReflectionList *ce image_feature_list_free(rflist); - cd.a.x /= n_a; cd.a.y /= n_a; cd.a.z /= n_a; - cd.b.x /= n_b; cd.b.y /= n_b; cd.b.z /= n_b; - cd.c.x /= n_c; cd.c.y /= n_c; cd.c.z /= n_c; + if ( n_a ) { + cd.a.x /= n_a; cd.a.y /= n_a; cd.a.z /= n_a; + } + if ( n_b ) { + cd.b.x /= n_b; cd.b.y /= n_b; cd.b.z /= n_b; + } + if ( n_c ) { + cd.c.x /= n_c; cd.c.y /= n_c; cd.c.z /= n_c; + } printf("Total distortion(a) = %+8e %+8e %+8e\n", cd.a.x, cd.a.y, cd.a.z); printf("Total distortion(b) = %+8e %+8e %+8e\n", cd.b.x, cd.b.y, cd.b.z); |