aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-09-30 14:09:17 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:00 +0100
commita04878fec9a9e76bf6266bc4b4bdfadb77b90441 (patch)
treee67dae00924dbd885b76e3a9334463548a794b88 /src
parent7c030ab77c830ab4e7a679f314fa413d126cea27 (diff)
Remove duplicated functionality of map_position() and get_q()
Diffstat (limited to 'src')
-rw-r--r--src/detector.c34
-rw-r--r--src/detector.h5
-rw-r--r--src/index.c10
-rw-r--r--src/peaks.c7
-rw-r--r--src/powder_plot.c6
5 files changed, 10 insertions, 52 deletions
diff --git a/src/detector.c b/src/detector.c
index e4c5a83e..be2b3a44 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -84,40 +84,6 @@ double get_tt(struct image *image, unsigned int xs, unsigned int ys)
}
-/* x,y in pixels relative to image origin */
-int map_position(struct image *image, double dx, double dy,
- double *rx, double *ry, double *rz)
-{
- double d;
- double twotheta, psi;
- const double k = 1.0 / image->lambda;
- struct panel *p;
- double x = 0.0;
- double y = 0.0;
-
- p = find_panel(image->det, dx, dy);
- if ( p == NULL ) return 1;
- if ( p->no_index ) return 1;
-
- x = ((double)dx - p->cx);
- y = ((double)dy - p->cy);
-
- /* Convert pixels to metres */
- x /= p->res;
- y /= p->res; /* Convert pixels to metres */
- d = sqrt((x*x) + (y*y));
- twotheta = atan2(d, p->clen);
-
- psi = atan2(y, x);
-
- *rx = k*sin(twotheta)*cos(psi);
- *ry = k*sin(twotheta)*sin(psi);
- *rz = k - k*cos(twotheta);
-
- return 0;
-}
-
-
void record_image(struct image *image, int do_poisson)
{
int x, y;
diff --git a/src/detector.h b/src/detector.h
index df40d05b..854a765a 100644
--- a/src/detector.h
+++ b/src/detector.h
@@ -40,11 +40,6 @@ struct detector
int n_panels;
};
-
-/* x,y in pixels relative to central beam */
-extern int map_position(struct image *image, double x, double y,
- double *rx, double *ry, double *rz);
-
extern struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys,
unsigned int sampling, float *ttp, float k);
diff --git a/src/index.c b/src/index.c
index 8d4b5dd6..c01412ed 100644
--- a/src/index.c
+++ b/src/index.c
@@ -102,24 +102,20 @@ static void write_drx(struct image *image)
void map_all_peaks(struct image *image)
{
int i;
- int nc = 0;
/* Map positions to 3D */
for ( i=0; i<image_feature_count(image->features); i++ ) {
struct imagefeature *f;
- int c;
+ struct rvec r;
f = image_get_feature(image->features, i);
if ( f == NULL ) continue;
- c = map_position(image, f->x, f->y, &f->rx, &f->ry, &f->rz);
- if ( c != 0 ) nc++;
+ r = get_q(image, f->x, f->y, 1, NULL, 1.0/image->lambda);
+ f->rx = r.u; f->ry = r.v; f->rz = r.w;
}
- if ( nc ) {
- ERROR("Failed to map %i reflections\n", nc);
- }
}
diff --git a/src/peaks.c b/src/peaks.c
index b0a905eb..0d35c930 100644
--- a/src/peaks.c
+++ b/src/peaks.c
@@ -429,14 +429,15 @@ void dump_peaks(struct image *image, pthread_mutex_t *mutex)
for ( i=0; i<image_feature_count(image->features); i++ ) {
- double q, rx, ry, rz;
struct imagefeature *f;
+ struct rvec r;
+ double q;
f = image_get_feature(image->features, i);
if ( f == NULL ) continue;
- map_position(image, f->x, f->y, &rx, &ry, &rz);
- q = modulus(rx, ry, rz);
+ r = get_q(image, f->x, f->y, 1, NULL, 1.0/image->lambda);
+ q = modulus(r.u, r.v, r.w);
printf("%8.3f %8.3f %8.3f %12.3f\n",
f->x, f->y, q/1.0e9, f->intensity);
diff --git a/src/powder_plot.c b/src/powder_plot.c
index f721d02e..d9049cc3 100644
--- a/src/powder_plot.c
+++ b/src/powder_plot.c
@@ -107,12 +107,12 @@ int main(int argc, char *argv[])
for ( x=0; x<image.width; x++ ) {
for ( y=0; y<image.height; y++ ) {
- double rx, ry, rz;
double q;
int intensity;
+ struct rvec r;
- map_position(&image, x, y, &rx, &ry, &rz);
- q = modulus(rx, ry, rz);
+ r = get_q(&image, x, y, 1, NULL, 1.0/image.lambda);
+ q = modulus(r.u, r.v, r.w);
intensity = image.data[x + image.width*y];