diff options
author | Thomas White <taw@bitwiz.org.uk> | 2010-02-20 17:09:54 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2010-02-20 17:12:11 +0100 |
commit | fc78b8c7c8c8b8c240a2861142627cc3877c26e7 (patch) | |
tree | 35bcfa84dec72833f036cc84e8994250024b2b91 | |
parent | 7f843558638a5ae289d23b9f9c053a431db6ed48 (diff) |
Fix get_q, which was distorting reciprocal space previously
-rw-r--r-- | data/diffraction.cl | 9 | ||||
-rw-r--r-- | src/diffraction.c | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/data/diffraction.cl b/data/diffraction.cl index b0f7b6b6..bac0c5c7 100644 --- a/data/diffraction.cl +++ b/data/diffraction.cl @@ -48,7 +48,7 @@ float4 get_q(int x, int y, float cx, float cy, float res, float clen, float k, float *ttp, float4 z, int sampling) { float rx, ry, r; - float ttx, tty, tt; + float az, tt; float4 q; rx = ((float)x - sampling*cx)/(res*sampling); @@ -56,13 +56,12 @@ float4 get_q(int x, int y, float cx, float cy, float res, float clen, float k, r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); - ttx = atan2(rx, clen); - tty = atan2(ry, clen); tt = atan2(r, clen); - *ttp = tt; - q = (float4)(k*sin(ttx), k*sin(tty), k-k*cos(tt), 0.0); + az = atan2(ry, rx); + + q = (float4)(k*sin(tt)*cos(az), k*sin(tt)*sin(az), k-k*cos(tt), 0.0); return quat_rot(q, z); } diff --git a/src/diffraction.c b/src/diffraction.c index 6df00164..bcfee476 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -141,7 +141,7 @@ struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, unsigned int sampling, float *ttp, float k) { struct rvec q; - float twothetax, twothetay, twotheta, r; + float twotheta, r, az; float rx = 0.0; float ry = 0.0; int p; @@ -164,14 +164,13 @@ struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, /* Calculate q-vector for this sub-pixel */ r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); - twothetax = atan2(rx, image->det.panels[p].clen); - twothetay = atan2(ry, image->det.panels[p].clen); - twotheta = atan2(r, image->det.panels[p].clen); + twotheta = atan2(r, image->det.panels[p].clen); + az = atan2(ry, rx); if ( ttp != NULL ) *ttp = twotheta; - q.u = k * sin(twothetax); - q.v = k * sin(twothetay); + q.u = k * sin(twotheta)*cos(az); + q.v = k * sin(twotheta)*sin(az); q.w = k - k * cos(twotheta); return quat_rot(q, image->orientation); |