cae-tools/solidify/face.h

72 lines
1.3 KiB
C

/*
* face.h - Data structure and handling of one face of a part
*
* Written 2010 by Werner Almesberger
* Copyright 2010 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef FACE_H
#define FACE_H
#include <math.h>
#include "array.h"
#include "matrix.h"
struct face {
struct array *a;
double x_step, y_step, z_step;
int sx, sy, sz; /* size */
int cx, cy; /* center */
int z_ref;
double fx, fy; /* inclination factor */
struct matrix m;
};
static inline double face_z0(const struct face *f, int x, int y)
{
return f->z_ref+f->fx*(x-f->sx/2)+f->fy*(y-f->sy/2);
}
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*z0_scale(f))/M_PI*180;
}
static inline double fy_to_angle(const struct face *f)
{
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)/z0_scale(f);
}
static inline void fy_from_angle(struct face *f, double a)
{
f->fy = tan(a/180*M_PI)/z0_scale(f);
}
struct face *read_face(const char *name);
#endif /* !FACE_H */