From 5d22ee1971a09a12910e2d03ac7dabfc159c1924 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 25 Jul 2010 22:36:15 +0200 Subject: render_hkl: Allow other zone axes --- src/render_hkl.c | 187 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 126 insertions(+), 61 deletions(-) (limited to 'src/render_hkl.c') diff --git a/src/render_hkl.c b/src/render_hkl.c index 5a3014ec..06075131 100644 --- a/src/render_hkl.c +++ b/src/render_hkl.c @@ -76,7 +76,8 @@ static void show_help(const char *s) #ifdef HAVE_CAIRO -static void render_za(UnitCell *cell, double *ref, unsigned int *c, +static void render_za(UnitCell *cell, ReflItemList *items, + double *ref, unsigned int *c, double boost, const char *sym, int wght, int colscale) { cairo_surface_t *surface; @@ -85,16 +86,36 @@ static void render_za(UnitCell *cell, double *ref, unsigned int *c, double scale_u, scale_v, scale; double sep_u, sep_v, max_r; double u, v; - signed int max_h, max_k; + signed int max_ux, max_uy; double as, bs, theta; double asx, asy, asz; double bsx, bsy, bsz; double csx, csy, csz; - signed int h, k; float wh, ht; + signed int xh, xk, xl; + signed int yh, yk, yl; + signed int zh, zk, zl; + double xx, xy, xz; + double yx, yy, yz; + signed int xi, yi; + char tmp[256]; + cairo_text_extents_t size; + double cx, cy; + const double border = 200.0; + + xh = 1; xk = -1; xl = 0; + yh = 0; yk = 0; yl = 1; + + zh = xk*yl - xl*yk; + zk = - xh*yl + xl*yh; + zl = xh*yk - xk*yh; + + STATUS("Zone axis is %i %i %i\n", zh, zk, zl); wh = 1024; ht = 1024; + cx = 512.0; + cy = 500.0; surface = cairo_pdf_surface_create("za.pdf", wh, ht); @@ -112,7 +133,7 @@ static void render_za(UnitCell *cell, double *ref, unsigned int *c, cairo_fill(dctx); max_u = 0.0; max_v = 0.0; max_val = 0.0; - max_res = 0.0; max_h = 0; max_k = 0; + max_res = 0.0; max_ux = 0; max_uy = 0; /* Work out reciprocal lattice spacings and angles for this cut */ if ( cell_get_reciprocal(cell, &asx, &asy, &asz, @@ -121,31 +142,47 @@ static void render_za(UnitCell *cell, double *ref, unsigned int *c, ERROR("Couldn't get reciprocal parameters\n"); return; } - theta = angle_between(asx, asy, asz, bsx, bsy, bsz); - as = modulus(asx, asy, asz) / 1e9; - bs = modulus(bsx, bsy, bsz) / 1e9; - - for ( h=-INDMAX; h0.0) ? sqrt(val) : 0.0; break; case WGHT_COUNTS : val = (float)ct; - val /= (float)num_equivs(h, k, 0, sym); + val /= (float)num_equivs(h, k, l, sym); break; case WGHT_RAWCOUNTS : val = (float)ct; @@ -155,22 +192,28 @@ static void render_za(UnitCell *cell, double *ref, unsigned int *c, abort(); } - nequiv = num_equivs(h, k, 0, sym); + nequiv = num_equivs(h, k, l, sym); for ( p=0; p fabs(max_u) ) max_u = fabs(u); if ( fabs(v) > fabs(max_v) ) max_v = fabs(v); if ( fabs(val) > fabs(max_val) ) { max_val = fabs(val); } - if ( fabs(he) > max_h ) max_h = fabs(he); - if ( fabs(ke) > max_k ) max_k = fabs(ke); - res = resolution(cell, he, ke, 0); + if ( fabs(ux) > max_ux ) max_ux = fabs(ux); + if ( fabs(uy) > max_uy ) max_uy = fabs(uy); + res = resolution(cell, he, ke, le); if ( res > max_res ) max_res = res; } @@ -189,36 +232,52 @@ static void render_za(UnitCell *cell, double *ref, unsigned int *c, } /* Choose whichever scaling factor gives the smallest value */ - scale_u = ((double)(wh/2.0)-50.0) / max_u; - scale_v = ((double)(ht/2.0)-50.0) / max_v; + scale_u = ((double)wh-border) / (2.0*max_u); + scale_v = ((double)ht-border) / (2.0*max_v); scale = (scale_u < scale_v) ? scale_u : scale_v; - sep_u = as * scale * cos(theta); - sep_v = bs * scale; + sep_u = (double)scale*as*sin(theta); + sep_v = (double)scale*as*cos(theta) + scale*bs; + /* We are interested in the smaller of the two separations */ max_r = (sep_u < sep_v) ? sep_u : sep_v; + max_r /= 2.0; /* Max radius if half the separation */ max_r -= 1.0; /* Add a tiny separation between circles */ + if ( max_r < 1.0 ) { + ERROR("Circle radius is probably too small (%f).\n", max_r); + } - for ( h=-INDMAX; h0.0) ? sqrt(val) : 0.0; break; case WGHT_COUNTS : val = (float)ct; - val /= (float)num_equivs(h, k, 0, sym); + val /= (float)num_equivs(h, k, l, sym); break; case WGHT_RAWCOUNTS : val = (float)ct; @@ -228,19 +287,23 @@ static void render_za(UnitCell *cell, double *ref, unsigned int *c, abort(); } - nequiv = num_equivs(h, k, 0, sym); + nequiv = num_equivs(h, k, l, sym); for ( p=0; p