Date:2010-09-25 08:15:11 (13 years 5 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
169169    m->b[1] += f->cy;
170170
171171    /*
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))
174181     */
175182
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);
178185
179186    m->a[0][0] *= f_x;
180187    m->a[0][1] *= f_x;
solidify/project.c
7171
7272    if (fscanf(file, "%f", &v) != 1)
7373        return;
74    f->fx = sin(v/180*M_PI);
74    f->fx = tan(v/180*M_PI);
7575
7676    if (fscanf(file, "%f", &v) != 1)
7777        return;
78    f->fy = sin(v/180*M_PI);
78    f->fy = tan(v/180*M_PI);
7979
8080    if (fscanf(file, "%f", &v) != 1)
8181        return;
...... 
152152        a = 180-a;
153153    if (fprintf(file, "%g %g %g\n%g %g %g\n",
154154        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,
156156        a, f->m.b[0]*f->x_step, f->m.b[1]*f->y_step) < 0) {
157157        perror(name);
158158        exit(1);

Archive Download the corresponding diff file

Branches:
master



interactive