Cleaned up z0 plane input/output. Note: need to change fx in all .sfy files !

- solidify/face.h (fx_to_angle, fy_to_angle, fx_from_angle, fy_from_angle):
  helper functions to get/set the z0 plane inclination
- solidify/povray.c (povray_face), solidify/project.c (read_face_data,
  save_face_data): use helper functions to get/set z0 plane
- solidify/project.c (read_face_data, save_face_data): don't negate fx
This commit is contained in:
Werner Almesberger 2010-09-27 00:54:39 -03:00
parent 12f5aa2188
commit 1638123771
3 changed files with 30 additions and 4 deletions

View File

@ -13,6 +13,8 @@
#ifndef FACE_H
#define FACE_H
#include <math.h>
#include "array.h"
#include "matrix.h"
@ -34,6 +36,30 @@ static inline double face_z0(const struct face *f, int x, int y)
}
static inline double fx_to_angle(const struct face *f)
{
return atan(f->fx)/M_PI*180;
}
static inline double fy_to_angle(const struct face *f)
{
return atan(f->fy)/M_PI*180;
}
static inline void fx_from_angle(struct face *f, double a)
{
f->fx = tan(a/180*M_PI);
}
static inline void fy_from_angle(struct face *f, double a)
{
f->fy = tan(a/180*M_PI);
}
struct face *read_face(const char *name);
#endif /* !FACE_H */

View File

@ -109,7 +109,7 @@ static void povray_face(FILE *file, const struct face *f, const char *side,
"\t}\n", prefix, side,
f->sx*f->x_step, (f->sz-1)*f->z_step, f->sy*f->y_step,
-f->sx*f->x_step/2, f->sy*f->y_step/2,
-atan(f->fy)/M_PI*180, atan(f->fx)/M_PI*180,
-fy_to_angle(f), fx_to_angle(f),
f->a->min_z*f->z_step,
-f->z_ref*f->z_step,
a,

View File

@ -72,11 +72,11 @@ static void read_face_data(FILE *file, struct face *f)
if (fscanf(file, "%f", &v) != 1)
return;
f->fx = -tan(v/180*M_PI);
fx_from_angle(f, v);
if (fscanf(file, "%f", &v) != 1)
return;
f->fy = tan(v/180*M_PI);
fy_from_angle(f, v);
if (fscanf(file, "%f", &v) != 1)
return;
@ -163,7 +163,7 @@ static void save_face_data(FILE *file, const char *name, const struct face *f)
a = 180-a;
if (fprintf(file, "%g %g %g\n%g %g %g\n",
f->z_ref*f->z_step,
-atan(f->fx)/M_PI*180, atan(f->fy)/M_PI*180,
fx_to_angle(f), fy_to_angle(f),
a, f->m.b[0]*f->x_step, f->m.b[1]*f->y_step) < 0) {
perror(name);
exit(1);