Correct z0 for z vs. xy scale differences. Now things work as planned !

- solidify/face.h (z0_scale, fx_to_angle, fy_to_angle, fx_from_angle,
  fy_from_angle): correct for z vs. xy scale differences
- solidify/overlap.c (merge_matrix): correct z0 shrinkage for z vs. xy
  scale differences
This commit is contained in:
Werner Almesberger 2010-09-27 02:39:25 -03:00
parent 1638123771
commit 6acca4ea4a
2 changed files with 13 additions and 6 deletions

View File

@ -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);
}

View File

@ -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;