diff options
author | Thomas White <taw@physics.org> | 2010-09-29 17:37:49 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:00 +0100 |
commit | 0da8b0efa29a1d581a15ffacafec5e1e5dec76ea (patch) | |
tree | ee465c0fe0710520882a16fe6328c12a12e22380 /src/detector.c | |
parent | fb8fc1fab3792488e5f3ab0e2ef9ed89189c47d9 (diff) |
Move get_q() and get_tt() to detector.c
Diffstat (limited to 'src/detector.c')
-rw-r--r-- | src/detector.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/detector.c b/src/detector.c index ce5aa82e..e4c5a83e 100644 --- a/src/detector.c +++ b/src/detector.c @@ -14,6 +14,7 @@ #include <math.h> #include <stdio.h> #include <string.h> +#include <assert.h> #include "image.h" #include "utils.h" @@ -30,6 +31,59 @@ int atob(const char *a) } +struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, + unsigned int sampling, float *ttp, float k) +{ + struct rvec q; + float twotheta, r, az; + float rx; + float ry; + struct panel *p; + + const unsigned int x = xs / sampling; + const unsigned int y = ys / sampling; /* Integer part only */ + + p = find_panel(image->det, x, y); + assert(p != NULL); + + 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, p->clen); + az = atan2(ry, rx); + if ( ttp != NULL ) *ttp = twotheta; + + q.u = k * sin(twotheta)*cos(az); + q.v = k * sin(twotheta)*sin(az); + q.w = k - k * cos(twotheta); + + return quat_rot(q, image->orientation); +} + + +double get_tt(struct image *image, unsigned int xs, unsigned int ys) +{ + float r, rx, ry; + struct panel *p; + + const unsigned int x = xs; + const unsigned int y = ys; /* Integer part only */ + + p = find_panel(image->det, x, y); + + rx = ((float)xs - p->cx) / p->res; + ry = ((float)ys - p->cy) / p->res; + + /* Calculate q-vector for this sub-pixel */ + r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); + + return atan2(r, p->clen); +} + + /* x,y in pixels relative to image origin */ int map_position(struct image *image, double dx, double dy, double *rx, double *ry, double *rz) |