aboutsummaryrefslogtreecommitdiff
path: root/src/diffraction.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-02-28 15:25:04 +0100
committerThomas White <taw@physics.org>2014-02-28 15:25:04 +0100
commitbea8ba818ef735fa2d667f132c90471da15ae1d1 (patch)
tree75a1125ea11157721a839c7744b4a6dfa36b50fd /src/diffraction.c
parentb6ec4053a99b1c0b584a20af189a1a48db89f908 (diff)
pattern_sim: Add --no-fringes
Diffstat (limited to 'src/diffraction.c')
-rw-r--r--src/diffraction.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/diffraction.c b/src/diffraction.c
index 0fa9f79b..6383a8b4 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -49,7 +49,7 @@
#define SINC_LUT_ELEMENTS (4096)
-static double *get_sinc_lut(int n)
+static double *get_sinc_lut(int n, int no_fringes)
{
int i;
double *lut;
@@ -64,7 +64,11 @@ static double *get_sinc_lut(int n)
for ( i=1; i<SINC_LUT_ELEMENTS; i++ ) {
double x, val;
x = (double)i/SINC_LUT_ELEMENTS;
- val = fabs(sin(M_PI*n*x)/sin(M_PI*x));
+ if ( no_fringes && (x > 1.0/n) && (1.0-x > 1.0/n) ) {
+ val = 0.0;
+ } else {
+ val = fabs(sin(M_PI*n*x)/sin(M_PI*x));
+ }
lut[i] = val;
}
}
@@ -665,7 +669,7 @@ struct sample *generate_twocolour(struct image *image)
void get_diffraction(struct image *image, int na, int nb, int nc,
const double *intensities, const double *phases,
const unsigned char *flags, UnitCell *cell,
- GradientMethod m, const SymOpList *sym)
+ GradientMethod m, const SymOpList *sym, int no_fringes)
{
double ax, ay, az;
double bx, by, bz;
@@ -683,9 +687,9 @@ void get_diffraction(struct image *image, int na, int nb, int nc,
/* Needed later for Lorentz calculation */
image->twotheta = malloc(image->width * image->height * sizeof(double));
- lut_a = get_sinc_lut(na);
- lut_b = get_sinc_lut(nb);
- lut_c = get_sinc_lut(nc);
+ lut_a = get_sinc_lut(na, no_fringes);
+ lut_b = get_sinc_lut(nb, no_fringes);
+ lut_c = get_sinc_lut(nc, no_fringes);
for ( i=0; i<image->nsamples; i++ ) {