aboutsummaryrefslogtreecommitdiff
path: root/src/render_hkl.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-07-27 22:13:12 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:54 +0100
commit51017e023cf71fc6265b8d074a1932cebfaed44c (patch)
tree6f4ed8989bf68f1c305dac73873fdbbd5332952a /src/render_hkl.c
parent994774918053cb3944313686eb7e9cb1970bbf5b (diff)
render_hkl: Remove stupid unnecessary iteration
Diffstat (limited to 'src/render_hkl.c')
-rw-r--r--src/render_hkl.c81
1 files changed, 37 insertions, 44 deletions
diff --git a/src/render_hkl.c b/src/render_hkl.c
index 403a9fa7..f0050f4e 100644
--- a/src/render_hkl.c
+++ b/src/render_hkl.c
@@ -189,7 +189,6 @@ static void draw_circles(signed int xh, signed int xk, signed int xl,
for ( yi=-INDMAX; yi<INDMAX; yi++ ) {
double u, v, val, res;
- int nequiv, p;
signed int h, k, l;
h = xi*xh + yi*yh;
@@ -221,62 +220,56 @@ static void draw_circles(signed int xh, signed int xk, signed int xl,
abort();
}
- /* For each equivalent reflection... */
- nequiv = num_equivs(h, k, l, sym);
- for ( p=0; p<nequiv; p++ ) {
+ signed int he, ke, le;
+ signed int ux, uy, uz;
- signed int he, ke, le;
- signed int ux, uy, uz;
+ find_unique_equiv(items, h, k, l, sym, &he, &ke, &le);
- get_equiv(h, k, l, &he, &ke, &le, sym, p);
+ /* Calculate the indices in the 2D basis */
+ ux = he*bc[0] + ke*bc[1] + le*bc[2];
+ uy = he*bc[3] + ke*bc[4] + le*bc[5];
+ uz = he*bc[6] + ke*bc[7] + le*bc[8];
- /* Calculate the indices in the 2D basis */
- ux = he*bc[0] + ke*bc[1] + le*bc[2];
- uy = he*bc[3] + ke*bc[4] + le*bc[5];
- uz = he*bc[6] + ke*bc[7] + le*bc[8];
+ /* Reflection in the zone? */
+ if ( uz != 0 ) continue;
- /* Reflection in the zone? */
- if ( uz != 0 ) continue;
+ /* Absolute location in image based on 2D basis */
+ u = (double)ux*as*sin(theta);
+ v = (double)ux*as*cos(theta) + (double)uy*bs;
- /* Absolute location in image based on 2D basis */
- u = (double)ux*as*sin(theta);
- v = (double)ux*as*cos(theta) + (double)uy*bs;
+ if ( dctx != NULL ) {
- if ( dctx != NULL ) {
+ float r, g, b;
- float r, g, b;
+ cairo_arc(dctx, ((double)cx)+u*scale,
+ ((double)cy)+v*scale,
+ radius, 0, 2*M_PI);
- cairo_arc(dctx, ((double)cx)+u*scale,
- ((double)cy)+v*scale,
- radius, 0, 2*M_PI);
+ render_scale(val, *max_val/boost, colscale,
+ &r, &g, &b);
+ cairo_set_source_rgb(dctx, r, g, b);
+ cairo_fill(dctx);
- render_scale(val, *max_val/boost, colscale,
- &r, &g, &b);
- cairo_set_source_rgb(dctx, r, g, b);
- cairo_fill(dctx);
+ } else {
- } else {
+ /* Find max vectors in plane for scaling */
+ if ( fabs(u) > fabs(*max_u) ) *max_u = fabs(u);
+ if ( fabs(v) > fabs(*max_v) ) *max_v = fabs(v);
- /* Find max vectors in plane for scaling */
- if ( fabs(u) > fabs(*max_u) ) *max_u = fabs(u);
- if ( fabs(v) > fabs(*max_v) ) *max_v = fabs(v);
-
- /* Find max value for colour scale */
- if ( fabs(val) > fabs(*max_val) ) {
- *max_val = fabs(val);
- }
-
- /* Find max indices */
- if ( (uy==0) && (fabs(ux) > *max_ux) )
- *max_ux = fabs(ux);
- if ( (ux==0) && (fabs(uy) > *max_uy) )
- *max_uy = fabs(uy);
-
- /* Find max resolution */
- res = resolution(cell, he, ke, le);
- if ( res > *max_res ) *max_res = res;
+ /* Find max value for colour scale */
+ if ( fabs(val) > fabs(*max_val) ) {
+ *max_val = fabs(val);
}
+ /* Find max indices */
+ if ( (uy==0) && (fabs(ux) > *max_ux) )
+ *max_ux = fabs(ux);
+ if ( (ux==0) && (fabs(uy) > *max_uy) )
+ *max_uy = fabs(uy);
+
+ /* Find max resolution */
+ res = resolution(cell, he, ke, le);
+ if ( res > *max_res ) *max_res = res;
}
}