Ben NanoNote 3D scans
Sign in or create your account | Project List | Help
Ben NanoNote 3D scans Commit Details
Date: | 2010-09-25 08:15:11 (12 years 11 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 98b6050e8369bfac26c57d7e6dee847ba2e0c074 |
Message: | Fix our trigonometry: the z0 inclination is expressed as a tangent,
not a sine. - solidify/project.c (read_face_data, save_face_data): fx/fy represent a tangent, not a sine - solidify/overlap.c (merge_matrix): corrected shrinkage formula to use tangent instead of sine |
Files: |
solidify/overlap.c (1 diff) solidify/project.c (2 diffs) |
Change Details
solidify/overlap.c | ||
---|---|---|
169 | 169 | m->b[1] += f->cy; |
170 | 170 | |
171 | 171 | /* |
172 | * Apply shrinkage caused by rotation out of z0. We use that | |
173 | * cos a = sqrt(1-sin^2 a) | |
172 | * Apply shrinkage caused by rotation out of z0. | |
173 | * We need to divide by x = cos a. We have f = tan a. | |
174 | * With sin^2 a + cos^2 a = 1, we get | |
175 | * | |
176 | * f = sqrt(1-cos^2 a)/cos a | |
177 | * = sqrt(1-x^2)/x | |
178 | * f^2 = 1/x^2-1 | |
179 | * 1/(f^2+1) = x^2 | |
180 | * cos a = sqrt(1/(f^2+1)) | |
174 | 181 | */ |
175 | 182 | |
176 | f_x = 1.0/sqrt(1-f->fx*f->fx); | |
177 | f_y = 1.0/sqrt(1-f->fy*f->fy); | |
183 | f_x = sqrt(f->fx*f->fx+1); | |
184 | f_y = sqrt(f->fy*f->fy+1); | |
178 | 185 | |
179 | 186 | m->a[0][0] *= f_x; |
180 | 187 | m->a[0][1] *= f_x; |
solidify/project.c | ||
---|---|---|
71 | 71 | |
72 | 72 | if (fscanf(file, "%f", &v) != 1) |
73 | 73 | return; |
74 | f->fx = sin(v/180*M_PI); | |
74 | f->fx = tan(v/180*M_PI); | |
75 | 75 | |
76 | 76 | if (fscanf(file, "%f", &v) != 1) |
77 | 77 | return; |
78 | f->fy = sin(v/180*M_PI); | |
78 | f->fy = tan(v/180*M_PI); | |
79 | 79 | |
80 | 80 | if (fscanf(file, "%f", &v) != 1) |
81 | 81 | return; |
... | ... | |
152 | 152 | a = 180-a; |
153 | 153 | if (fprintf(file, "%g %g %g\n%g %g %g\n", |
154 | 154 | f->z_ref*f->z_step, |
155 | asin(f->fx)/M_PI*180, asin(f->fy)/M_PI*180, | |
155 | atan(f->fx)/M_PI*180, atan(f->fy)/M_PI*180, | |
156 | 156 | a, f->m.b[0]*f->x_step, f->m.b[1]*f->y_step) < 0) { |
157 | 157 | perror(name); |
158 | 158 | exit(1); |
Branches:
master