blob: 60784da7472ce7a8fedceaabb5fbd1085b9c2d98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* reax.c
*
* A new auto-indexer
*
* (c) 2011 Thomas White <taw@physics.org>
*
* Part of CrystFEL - crystallography with a FEL
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "image.h"
#include "utils.h"
#include "peaks.h"
#include "cell.h"
#include "index.h"
#include "index-priv.h"
struct dvec
{
double x;
double y;
double z;
};
struct reax_private
{
IndexingPrivate base;
struct dvec *directions;
};
IndexingPrivate *reax_prepare()
{
struct reax_private *priv;
int ui, vi;
int samp;
double angular_inc;
priv = calloc(1, sizeof(*priv));
if ( priv == NULL ) return NULL;
priv->base.indm = INDEXING_REAX;
/* Decide on sampling interval */
angular_inc = 0.03; /* From Steller (1997) */
samp = (2.0 * M_PI) / angular_inc;
priv->directions = malloc(samp*samp*sizeof(struct dvec));
if ( priv == NULL) {
free(priv);
return NULL;
}
for ( ui=0; ui<samp; ui++ ) {
for ( vi=0; vi<samp; vi++ ) {
double u, v;
double th, ph;
struct dvec *dir;
u = (double)ui/samp;
v = (double)vi/samp;
th = 2.0 * M_PI * u;
ph = acos(2.0*v - 1.0);
dir = &priv->directions[ui + vi*samp];
dir->x = cos(th) * sin(ph);
dir->y = sin(th) * sin(th);
dir->z = cos(ph);
}
}
return (IndexingPrivate *)priv;
}
void reax_index(struct image *image, UnitCell *cell)
{
}
|