1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* genblind2.c - make some curved or flat venetian blinds. |
6 |
|
* |
16 |
|
*/ |
17 |
|
|
18 |
|
#include <stdio.h> |
19 |
+ |
#include <stdlib.h> |
20 |
|
#include <math.h> |
21 |
+ |
#include <string.h> |
22 |
|
|
23 |
|
#define PI 3.14159265358979323846 |
24 |
|
#define DELTA 10. /* MINIMAL SUSTAINED ANGLE IN DEGREES */ |
29 |
|
double height; |
30 |
|
int nslats, nsurf; |
31 |
|
|
33 |
– |
#ifdef DCL_ATOF |
34 |
– |
extern double atof(); |
35 |
– |
#endif |
32 |
|
|
33 |
|
|
34 |
+ |
makeflat(w,d,a) |
35 |
+ |
double w, d, a; |
36 |
+ |
{ |
37 |
+ |
double h; |
38 |
+ |
|
39 |
+ |
h = d*sin(a); |
40 |
+ |
d *= cos(a); |
41 |
+ |
baseflat[0][0] = 0.0; |
42 |
+ |
baseflat[0][1] = 0.0; |
43 |
+ |
baseflat[0][2] = 0.0; |
44 |
+ |
baseflat[1][0] = 0.0; |
45 |
+ |
baseflat[1][1] = w; |
46 |
+ |
baseflat[1][2] = 0.0; |
47 |
+ |
baseflat[2][0] = d; |
48 |
+ |
baseflat[2][1] = w; |
49 |
+ |
baseflat[2][2] = h; |
50 |
+ |
baseflat[3][0] = d; |
51 |
+ |
baseflat[3][1] = 0.0; |
52 |
+ |
baseflat[3][2] = h; |
53 |
+ |
|
54 |
+ |
} |
55 |
+ |
|
56 |
+ |
|
57 |
+ |
printslat(n) /* print slat # n */ |
58 |
+ |
int n; |
59 |
+ |
{ |
60 |
+ |
register int i, k; |
61 |
+ |
|
62 |
+ |
for (k=0; k < nsurf; k++) { |
63 |
+ |
printf("\n%s polygon %s.%d.%d\n", material, name, n, k); |
64 |
+ |
printf("0\n0\n12\n"); |
65 |
+ |
for (i = 0; i < 4; i++) |
66 |
+ |
printf("\t%18.12g\t%18.12g\t%18.12g\n", |
67 |
+ |
baseblind[i][0][k], |
68 |
+ |
baseblind[i][1][k], |
69 |
+ |
baseblind[i][2][k] + height*(n-.5)/nslats); |
70 |
+ |
} |
71 |
+ |
} |
72 |
+ |
|
73 |
+ |
|
74 |
+ |
printhead(ac, av) /* print command header */ |
75 |
+ |
register int ac; |
76 |
+ |
register char **av; |
77 |
+ |
{ |
78 |
+ |
putchar('#'); |
79 |
+ |
while (ac--) { |
80 |
+ |
putchar(' '); |
81 |
+ |
fputs(*av++, stdout); |
82 |
+ |
} |
83 |
+ |
putchar('\n'); |
84 |
+ |
} |
85 |
+ |
|
86 |
+ |
|
87 |
|
main(argc, argv) |
88 |
|
int argc; |
89 |
|
char *argv[]; |
120 |
|
|
121 |
|
/* HOW MANY ELEMENTARY SURFACES SHOULD BE CALCULATED ? */ |
122 |
|
|
123 |
< |
nsurf = (theta / ((PI/180.)*DELTA)); |
123 |
> |
nsurf = (int)(theta / ((PI/180.)*DELTA)) + 1; |
124 |
|
|
125 |
|
/* WHAT IS THE DEPTH OF THE ELEMENTARY SURFACES ? */ |
126 |
|
|
201 |
|
} |
202 |
|
|
203 |
|
|
155 |
– |
makeflat(w,d,a) |
156 |
– |
double w, d, a; |
157 |
– |
{ |
158 |
– |
double h; |
204 |
|
|
160 |
– |
h = d*sin(a); |
161 |
– |
d *= cos(a); |
162 |
– |
baseflat[0][0] = 0.0; |
163 |
– |
baseflat[0][1] = 0.0; |
164 |
– |
baseflat[0][2] = 0.0; |
165 |
– |
baseflat[1][0] = 0.0; |
166 |
– |
baseflat[1][1] = w; |
167 |
– |
baseflat[1][2] = 0.0; |
168 |
– |
baseflat[2][0] = d; |
169 |
– |
baseflat[2][1] = w; |
170 |
– |
baseflat[2][2] = h; |
171 |
– |
baseflat[3][0] = d; |
172 |
– |
baseflat[3][1] = 0.0; |
173 |
– |
baseflat[3][2] = h; |
174 |
– |
|
175 |
– |
} |
176 |
– |
|
177 |
– |
|
178 |
– |
printslat(n) /* print slat # n */ |
179 |
– |
int n; |
180 |
– |
{ |
181 |
– |
register int i, k; |
182 |
– |
|
183 |
– |
for (k=0; k < nsurf; k++) { |
184 |
– |
printf("\n%s polygon %s.%d.%d\n", material, name, n, k); |
185 |
– |
printf("0\n0\n12\n"); |
186 |
– |
for (i = 0; i < 4; i++) |
187 |
– |
printf("\t%18.12g\t%18.12g\t%18.12g\n", |
188 |
– |
baseblind[i][0][k], |
189 |
– |
baseblind[i][1][k], |
190 |
– |
baseblind[i][2][k] + height*(n-.5)/nslats); |
191 |
– |
} |
192 |
– |
} |
193 |
– |
|
194 |
– |
|
195 |
– |
printhead(ac, av) /* print command header */ |
196 |
– |
register int ac; |
197 |
– |
register char **av; |
198 |
– |
{ |
199 |
– |
putchar('#'); |
200 |
– |
while (ac--) { |
201 |
– |
putchar(' '); |
202 |
– |
fputs(*av++, stdout); |
203 |
– |
} |
204 |
– |
putchar('\n'); |
205 |
– |
} |