aboutsummaryrefslogtreecommitdiff
path: root/src/detector.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-02-27 21:34:20 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:15 +0100
commit58db0aef18fe71d501d7712c7718e4e55324ee87 (patch)
treec12a7f3f3adf0cd53ef3fb77399ead0742b1849b /src/detector.c
parent7dd5cd690e3c61df638aaacad5d23617f72ff0da (diff)
hdfsee: Fit window to detector geometry
Diffstat (limited to 'src/detector.c')
-rw-r--r--src/detector.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/detector.c b/src/detector.c
index 633af6df..e4f15aff 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -515,3 +515,59 @@ struct detector *simple_geometry(const struct image *image)
return geom;
}
+
+
+static void check_extents(struct panel p, double *min_x, double *min_y,
+ double *max_x, double *max_y, double fs, double ss)
+{
+ double xs, ys, rx, ry;
+
+ xs = fs*p.fsx + ss*p.ssx;
+ ys = fs*p.fsy + ss*p.ssy;
+
+ rx = xs + p.cx;
+ ry = ys + p.cy;
+
+ if ( rx > *max_x ) *max_x = rx;
+ if ( ry > *max_y ) *max_y = ry;
+ if ( rx < *min_x ) *min_x = rx;
+ if ( ry < *min_y ) *min_y = ry;
+}
+
+
+void get_pixel_extents(struct detector *det,
+ double *min_x, double *min_y,
+ double *max_x, double *max_y)
+{
+ int i;
+
+ *min_x = 0.0;
+ *max_x = 0.0;
+ *min_y = 0.0;
+ *max_y = 0.0;
+
+ /* To determine the maximum extents of the detector, put all four
+ * corners of each panel through the transformations and watch for the
+ * biggest */
+
+ for ( i=0; i<det->n_panels; i++ ) {
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ 0.0,
+ 0.0);
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ 0.0,
+ det->panels[i].max_ss-det->panels[i].min_ss+1);
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ det->panels[i].max_fs-det->panels[i].min_fs+1,
+ 0.0);
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ det->panels[i].max_fs-det->panels[i].min_fs+1,
+ det->panels[i].max_ss-det->panels[i].min_ss+1);
+
+
+ }
+}