From 9d1d9790c6f1d7648776dab3222317a74d6b8dff Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 1 Jun 2013 09:51:34 -0700 Subject: Fix rounding of pixel coordinates --- libcrystfel/src/integration.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index 9e22a542..99721ea2 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -1127,8 +1127,15 @@ static void measure_all_intensities(IntegrationMethod meth, RefList *list, set_redundancy(refl, 0); get_detector_pos(refl, &pfs, &pss); - fid_fs = lrint(pfs); - fid_ss = lrint(pss); + + /* Explicit truncation of digits after the decimal point. + * This is actually the correct thing to do here, not + * e.g. lrint(). pfs/pss is the position of the spot, measured + * in numbers of pixels, from the panel corner (not the center + * of the first pixel). So any coordinate from 2.0 to 2.9999 + * belongs to pixel index 2. */ + fid_fs = pfs; + fid_ss = pss; pn = find_panel_number(image->det, fid_fs, fid_ss); p = &image->det->panels[pn]; @@ -1569,8 +1576,15 @@ static void integrate_rings(IntegrationMethod meth, Crystal *cr, set_redundancy(refl, 0); get_detector_pos(refl, &pfs, &pss); - fid_fs = lrint(pfs); - fid_ss = lrint(pss); + + /* Explicit truncation of digits after the decimal point. + * This is actually the correct thing to do here, not + * e.g. lrint(). pfs/pss is the position of the spot, measured + * in numbers of pixels, from the panel corner (not the center + * of the first pixel). So any coordinate from 2.0 to 2.9999 + * belongs to pixel index 2. */ + fid_fs = pfs; + fid_ss = pss; pn = find_panel_number(image->det, fid_fs, fid_ss); p = &image->det->panels[pn]; -- cgit v1.2.3