aboutsummaryrefslogtreecommitdiff
path: root/src/detector.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-03-01 14:33:09 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:16 +0100
commita4ca7e3e65e4fbd36062b9c4f8d26c78b97d3fde (patch)
tree5c4725af4dc26f22597453dc009cf57cf7dedb3d /src/detector.c
parent6341b8ee8d9be0b6fed14cf418161706e4caa5c5 (diff)
hdfsee: Do "numbers" according to geometry
Diffstat (limited to 'src/detector.c')
-rw-r--r--src/detector.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/detector.c b/src/detector.c
index 703a7189..34ae8bea 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -561,15 +561,55 @@ struct detector *simple_geometry(const struct image *image)
geom->panels[0].max_ss = image->height-1;
geom->panels[0].cnx = -image->width / 2.0;
geom->panels[0].cny = -image->height / 2.0;
+
geom->panels[0].fsx = 1;
geom->panels[0].fsy = 0;
geom->panels[0].ssx = 0;
geom->panels[0].ssy = 1;
+ geom->panels[0].xfs = 1;
+ geom->panels[0].xss = 0;
+ geom->panels[0].yfs = 0;
+ geom->panels[0].yss = 1;
+
return geom;
}
+int reverse_2d_mapping(double x, double y, double *pfs, double *pss,
+ struct detector *det)
+{
+ int i;
+
+ for ( i=0; i<det->n_panels; i++ ) {
+
+ struct panel *p = &det->panels[i];
+ double cx, cy, fs, ss;
+
+ /* Get position relative to corner */
+ cx = x - p->cnx;
+ cy = y - p->cny;
+
+ /* Reverse the transformation matrix */
+ fs = cx*p->xfs + cy*p->yfs;
+ ss = cx*p->xss + cy*p->yss;
+
+ /* In range? */
+ if ( fs < 0 ) continue;
+ if ( ss < 0 ) continue;
+ if ( fs > (p->max_fs-p->min_fs+1) ) continue;
+ if ( ss > (p->max_ss-p->min_ss+1) ) continue;
+
+ *pfs = fs + p->min_fs;
+ *pss = ss + p->min_ss;
+ return 0;
+
+ }
+
+ return 1;
+}
+
+
static void check_extents(struct panel p, double *min_x, double *min_y,
double *max_x, double *max_y, double fs, double ss)
{