# Ben NanoNote 3D scans Commit Details

Date: 2010-09-24 08:46:32 (9 years 2 months ago) Werner Almesberger f3e7c1ec73e233a372105723ea5ace07f58fc740 Various coordinate transform corrections in overlap.c- solidify/face.h (struct matrix), solidify/face.c (read_file): also record the face's center - solidify/overlap.c (point): reference faces to the screen center - solidify/overlap.c (point): use correct model coordinates for z0 calculation solidify/face.c (1 diff) solidify/face.h (1 diff) solidify/overlap.c (2 diffs)

## Change Details

solidify/face.c
7575    f->sx = f->a->max_x-f->a->min_x+1;
7676    f->sy = f->a->max_y-f->a->min_y+1;
7777
78    f->cx = (f->a->min_x+f->a->max_x)/2;
79    f->cy = (f->a->min_y+f->a->max_y)/2;
80
7881    h = make_histo(f->a);
7982    f->z_ref = f->a->min_z+median(h);
8083    free_histo(h);
solidify/face.h
3232struct face {
3333    struct array *a;
3434    int sx, sy; /* size */
35    int cx, cy; /* center */
3536    int z_ref;
3637    double fx, fy; /* inclination factor */
3738    struct matrix m;
solidify/overlap.c
8383}
8484
8585
86/*
87 * Coordinate transformations, on the example of the x coordinate:
88 *
89 * - the x coordinate runs from 0 to sx(s)-1
90 * - since we work relative to the screen center, this becomes x-sx(s)/2
91 * This is what we perform the coordinate transform on.
92 * - our model runs from min_x to max_x. Its center is at cx.
93 */
94
8695static void point(const struct solid *s, int x, int y, guchar *p)
8796{
8897    double za, zb, z;
89    int xa = x+s->a->a->min_x;
90    int ya = y+s->a->a->min_y;
91    int yb = sy(s)-1-y+s->a->a->min_y;
98    int xa, xb, ya, yb;
99    double xaf, xbf, yaf, ybf;
92100
93    za = zmix(s->a,
94        xa*s->a->m.a[0][0]+ya*s->a->m.a[0][1]+s->a->m.b[0],
95        xa*s->a->m.a[1][0]+ya*s->a->m.a[1][1]+s->a->m.b[1]);
101    xa = x-sx(s)/2;
102    ya = y-sy(s)/2;
103    xaf = xa*s->a->m.a[0][0]+ya*s->a->m.a[0][1]+s->a->m.b[0]+s->a->cx;
104    yaf = xa*s->a->m.a[1][0]+ya*s->a->m.a[1][1]+s->a->m.b[1]+s->a->cy;
105    za = zmix(s->a, xaf, yaf);
96106
97    zb = zmix(s->b,
98        xa*s->b->m.a[0][0]+yb*s->b->m.a[0][1]+s->b->m.b[0],
99        xa*s->b->m.a[1][0]+yb*s->b->m.a[1][1]+s->b->m.b[1]);
107    xb = x-sx(s)/2;
108    yb = (sy(s)-1)/2-y;
109    xbf = xb*s->b->m.a[0][0]+yb*s->b->m.a[0][1]+s->b->m.b[0]+s->b->cx;
110    ybf = xb*s->b->m.a[1][0]+yb*s->b->m.a[1][1]+s->b->m.b[1]+s->b->cy;
111    zb = zmix(s->b, xbf, ybf);
100112
101113    if (za == UNDEF_F && zb == UNDEF_F)
102114        return;
......
125137    }
126138
127139    z = za;
128    za -= face_z0(s->a, xa, ya);
129    zb -= face_z0(s->b, xa, yb);
140    za -= face_z0(s->a, xaf, yaf);
141    zb -= face_z0(s->b, xbf, ybf);
130142
131143    if (za+zb < -s->dist) {
132144        p[0] = 0;

Branches:
master