aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-10-01 18:37:48 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:01 +0100
commitf7a312058664d5f3e8c5176ba27bb593ae0f1b0d (patch)
treeed989170f334446e4db2120afdbe56f91e0afb69 /src
parentc56336d82f151b8eea7ce17cb34a177ba5656ecd (diff)
Don't lose precision when calculating q
Diffstat (limited to 'src')
-rw-r--r--src/detector.c17
-rw-r--r--src/detector.h4
2 files changed, 10 insertions, 11 deletions
diff --git a/src/detector.c b/src/detector.c
index 11e61b48..cc5663af 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -31,23 +31,22 @@ int atob(const char *a)
}
-struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys,
+struct rvec get_q(struct image *image, double xs, double ys,
unsigned int sampling, float *ttp, float k)
{
struct rvec q;
- float twotheta, r, az;
- float rx;
- float ry;
+ double twotheta, r, az;
+ double rx, ry;
struct panel *p;
+ /* Determine which panel to use */
const unsigned int x = xs / sampling;
- const unsigned int y = ys / sampling; /* Integer part only */
-
+ const unsigned int y = ys / sampling;
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);
+ rx = (xs - (sampling*p->cx)) / (sampling * p->res);
+ ry = (ys - (sampling*p->cy)) / (sampling * p->res);
/* Calculate q-vector for this sub-pixel */
r = sqrt(pow(rx, 2.0) + pow(ry, 2.0));
@@ -64,7 +63,7 @@ struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys,
}
-double get_tt(struct image *image, unsigned int xs, unsigned int ys)
+double get_tt(struct image *image, double xs, double ys)
{
float r, rx, ry;
struct panel *p;
diff --git a/src/detector.h b/src/detector.h
index f6b26c8c..720b5351 100644
--- a/src/detector.h
+++ b/src/detector.h
@@ -42,10 +42,10 @@ struct detector
int max_y; /* Size of overall array needed, minus 1 */
};
-extern struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys,
+extern struct rvec get_q(struct image *image, double xs, double ys,
unsigned int sampling, float *ttp, float k);
-extern double get_tt(struct image *image, unsigned int xs, unsigned int ys);
+extern double get_tt(struct image *image, double xs, double ys);
extern void record_image(struct image *image, int do_poisson);