From 2639321f2aa8e489f60b7cc60b4e4c89f990826e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 20 Mar 2009 12:36:41 +0000 Subject: Limit the resolution of reflections passed to DirAx --- src/dirax.c | 28 +++++++++++++++++----------- 1 file 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; jnext; } + + /* 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++; + } } -- cgit v1.2.3