From c080e2c362628da1a68ad17c117f303945724006 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 28 Feb 2011 17:11:00 +0100 Subject: First round of fallout from new geometry format --- src/geometry.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'src/geometry.c') diff --git a/src/geometry.c b/src/geometry.c index 33527f71..f8b74148 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -31,45 +31,54 @@ static signed int locate_peak(double x, double y, double z, double k, struct detector *det, double *xdap, double *ydap) { - int p; + int i; signed int found = -1; const double den = k + z; *xdap = -1; *ydap = -1; - for ( p=0; pn_panels; p++ ) { + for ( i=0; in_panels; i++ ) { double xd, yd, cl; - double xda, yda; + double fs, ss, plx, ply; + struct panel *p; + + p = &det->panels[i]; /* Camera length for this panel */ - cl = det->panels[p].clen; + cl = p->clen; /* Coordinates of peak relative to central beam, in m */ xd = cl * x / den; yd = cl * y / den; /* Convert to pixels */ - xd *= det->panels[p].res; - yd *= det->panels[p].res; + xd *= p->res; + yd *= p->res; + + /* Convert to relative to the panel corner */ + plx = xd - p->cnx; + ply = yd - p->cny; + + fs = p->xfs*plx + p->yfs*ply; + ss = p->xss*plx + p->yss*ply; - /* Add the coordinates of the central beam */ - xda = xd + det->panels[p].cx; - yda = yd + det->panels[p].cy; + fs += p->min_fs; + ss += p->min_ss; /* Now, is this on this panel? */ - if ( xda < det->panels[p].min_fs ) continue; - if ( xda > det->panels[p].max_fs ) continue; - if ( yda < det->panels[p].min_ss ) continue; - if ( yda > det->panels[p].max_ss ) continue; + if ( fs < p->min_fs ) continue; + if ( fs > p->max_fs ) continue; + if ( ss < p->min_ss ) continue; + if ( ss > p->max_ss ) continue; /* If peak appears on multiple panels, reject it */ if ( found != -1 ) return -1; /* Woohoo! */ - found = p; - *xdap = xda; - *ydap = yda; + found = i; + *xdap = fs; + *ydap = ss; } -- cgit v1.2.3