diff options
author | Thomas White <taw27@cam.ac.uk> | 2009-03-20 12:36:41 +0000 |
---|---|---|
committer | Thomas White <taw27@cam.ac.uk> | 2009-03-20 12:36:41 +0000 |
commit | 2639321f2aa8e489f60b7cc60b4e4c89f990826e (patch) | |
tree | 164902bde50d3acde12c38c0fe9b8a22b94a640a | |
parent | dc76f055cefcfc70f97f4c5520e65eec7e662fcf (diff) |
Limit the resolution of reflections passed to DirAx
-rw-r--r-- | src/dirax.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/dirax.c b/src/dirax.c index 7c79412..2c82833 100644 --- a/src/dirax.c +++ b/src/dirax.c @@ -377,23 +377,20 @@ static void dirax_send_random_selection(ReflectionList *r, int n, FILE *fh) used[i] = '-'; } - for ( i=0; i<1000; i++ ) { + i = 0; + while ( i < 1000 ) { Reflection *ref; - int done; int j; long long int ra; - done = 0; - while ( !done ) { - ra = ((long long int)random() * (long long int)n); - ra /= RAND_MAX; - if ( used[ra] == 'U' ) { - printf("%lli - already used\n", ra); - } else { - done = 1; - } + ra = ((long long int)random() * (long long int)n); + ra /= RAND_MAX; + if ( used[ra] == 'U' ) { + printf("%lli - already used\n", ra); + continue; } + printf("Selected reflection %lli\n", ra); /* Dig out the correct reflection. A little faffy @@ -402,11 +399,20 @@ static void dirax_send_random_selection(ReflectionList *r, int n, FILE *fh) for ( j=0; j<ra; j++ ) { ref = ref->next; } + + /* Limit resolution of reflections */ + if ( ( (ref->x/1e9)*(ref->x/1e9) + + (ref->y/1e9)*(ref->y/1e9) + + (ref->z/1e9)*(ref->z/1e9) ) > (20e9)*(20e9) ) + continue; + fprintf(fh, "%10f %10f %10f %8f\n", ref->x/1e10, ref->y/1e10, ref->z/1e10, ref->intensity); used[ra] = 'U'; + i++; + } } |