aboutsummaryrefslogtreecommitdiff
path: root/src/dirax.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dirax.c')
-rw-r--r--src/dirax.c28
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++;
+
}
}