diff --git a/solidify/face.h b/solidify/face.h index ab6c5cf..266b1d2 100644 --- a/solidify/face.h +++ b/solidify/face.h @@ -36,27 +36,33 @@ static inline double face_z0(const struct face *f, int x, int y) } +static inline double z0_scale(const struct face *f) +{ + return f->z_step/f->x_step; +} + + static inline double fx_to_angle(const struct face *f) { - return atan(f->fx)/M_PI*180; + return atan(f->fx*z0_scale(f))/M_PI*180; } static inline double fy_to_angle(const struct face *f) { - return atan(f->fy)/M_PI*180; + return atan(f->fy*z0_scale(f))/M_PI*180; } static inline void fx_from_angle(struct face *f, double a) { - f->fx = tan(a/180*M_PI); + f->fx = tan(a/180*M_PI)/z0_scale(f); } static inline void fy_from_angle(struct face *f, double a) { - f->fy = tan(a/180*M_PI); + f->fy = tan(a/180*M_PI)/z0_scale(f); } diff --git a/solidify/overlap.c b/solidify/overlap.c index 96ff593..22fab6e 100644 --- a/solidify/overlap.c +++ b/solidify/overlap.c @@ -158,6 +158,7 @@ static void merge_matrix(struct matrix *m, const struct solid *s, double tm[2][2], tm2[2][2]; double tv[2]; double f_x, f_y; + double z0s2 = z0_scale(f)*z0_scale(f); /* * Finally, we convert to model matrix coordinates. @@ -180,8 +181,8 @@ static void merge_matrix(struct matrix *m, const struct solid *s, * cos a = sqrt(1/(f^2+1)) */ - f_x = sqrt(f->fx*f->fx+1); - f_y = sqrt(f->fy*f->fy+1); + f_x = sqrt(f->fx*f->fx*z0s2+1); + f_y = sqrt(f->fy*f->fy*z0s2+1); m->a[0][0] *= f_x; m->a[0][1] *= f_x;