Root/solidify/face.h

Source at commit 525e1557ec1a8e924b25a86c1efe61c93da21179 created 8 years 11 months ago.
By Werner Almesberger, Use two faces and show how they overlap (in progress)
1/*
2 * face.h - Data structure and handling of one face of a part
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 by Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef FACE_H
14#define FACE_H
15
16#include "array.h"
17
18
19/*
20 * 2D transformation:
21 *
22 * x' = x*a[0][0]+y*a[0][1]+b[0]
23 * y' = x*a[1][0]+y*a[1][1]+b[1]
24 */
25
26
27struct matrix {
28    double a[2][2];
29    double b[2];
30};
31
32struct face {
33    struct array *a;
34    int sx, sy; /* size */
35    int z_ref;
36    double fx, fy; /* inclination factor */
37    struct matrix m;
38};
39
40
41static inline double face_z0(const struct face *f, int x, int y)
42{
43    return f->z_ref+f->fx*(x-f->sx/2)+f->fy*(y-f->sy/2);
44}
45
46
47struct face *read_face(const char *name);
48
49#endif /* FACE_H */
50

Archive Download this file

Branches:
master



interactive