diff options
author | Thomas White <taw@physics.org> | 2010-02-22 10:32:21 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-02-22 10:32:21 +0100 |
commit | f86c9795c72d0a75692f010c0f3ef37f1c899eca (patch) | |
tree | 95f9f8e8e28836be63dc25691eb07ace81f03101 /src/diffraction.c | |
parent | 79fcc8f0938f0d8056b7b745eb96b89d133a571e (diff) |
Add find_panel() routine to clean up a lot of things
Diffstat (limited to 'src/diffraction.c')
-rw-r--r-- | src/diffraction.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/diffraction.c b/src/diffraction.c index bcfee476..b24b68b0 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -144,28 +144,20 @@ struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, float twotheta, r, az; float rx = 0.0; float ry = 0.0; - int p; + struct panel *p; const unsigned int x = xs / sampling; const unsigned int y = ys / sampling; /* Integer part only */ - for ( p=0; p<image->det.n_panels; p++ ) { - if ( (x >= image->det.panels[p].min_x) - && (x <= image->det.panels[p].max_x) - && (y >= image->det.panels[p].min_y) - && (y <= image->det.panels[p].max_y) ) { - rx = ((float)xs - (sampling*image->det.panels[p].cx)) - / (sampling * image->det.panels[p].res); - ry = ((float)ys - (sampling*image->det.panels[p].cy)) - / (sampling * image->det.panels[p].res); - break; - } - } + p = find_panel(&image->det, x, y); + + rx = ((float)xs - (sampling*p->cx)) / (sampling * p->res); + ry = ((float)ys - (sampling*p->cy)) / (sampling * p->res); /* Calculate q-vector for this sub-pixel */ r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); - twotheta = atan2(r, image->det.panels[p].clen); + twotheta = atan2(r, p->clen); az = atan2(ry, rx); if ( ttp != NULL ) *ttp = twotheta; |