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.141592653589793 |
24 |
< |
#define DELTA 5. /* MINIMAL SUSTAINED ANGLE IN DEGREES */ |
23 |
> |
#define PI 3.14159265358979323846 |
24 |
> |
#define DELTA 10. /* MINIMAL SUSTAINED ANGLE IN DEGREES */ |
25 |
|
|
26 |
|
double baseflat[4][3], baseblind[4][3][180]; |
27 |
|
double A[3],X[3]; |
30 |
|
int nslats, nsurf; |
31 |
|
|
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[]; |
90 |
|
{ |
38 |
– |
double atof(), fabs(); |
91 |
|
double width, delem, depth, rcurv = 0.0, angle; |
92 |
|
double beta, gamma, theta, chi; |
93 |
|
int i, j, k, l; |
104 |
|
angle = atof(argv[7]); |
105 |
|
if (argc == 10) |
106 |
|
if (!strcmp(argv[8], "-r")) |
107 |
< |
rcurv = atof(argv[8]); |
107 |
> |
rcurv = atof(argv[9]); |
108 |
|
else if (!strcmp(argv[8], "+r")) |
109 |
< |
rcurv = -atof(argv[8]); |
109 |
> |
rcurv = -atof(argv[9]); |
110 |
|
else |
111 |
|
goto userr; |
112 |
|
|
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 |
|
|
152 |
– |
makeflat(w,d,a) |
153 |
– |
double w, d, a; |
154 |
– |
{ |
155 |
– |
double sin(), cos(); |
156 |
– |
double h; |
204 |
|
|
158 |
– |
h = d*sin(a); |
159 |
– |
d *= cos(a); |
160 |
– |
baseflat[0][0] = 0.0; |
161 |
– |
baseflat[0][1] = 0.0; |
162 |
– |
baseflat[0][2] = 0.0; |
163 |
– |
baseflat[1][0] = 0.0; |
164 |
– |
baseflat[1][1] = w; |
165 |
– |
baseflat[1][2] = 0.0; |
166 |
– |
baseflat[2][0] = d; |
167 |
– |
baseflat[2][1] = w; |
168 |
– |
baseflat[2][2] = h; |
169 |
– |
baseflat[3][0] = d; |
170 |
– |
baseflat[3][1] = 0.0; |
171 |
– |
baseflat[3][2] = h; |
172 |
– |
|
173 |
– |
} |
174 |
– |
|
175 |
– |
|
176 |
– |
printslat(n) /* print slat # n */ |
177 |
– |
int n; |
178 |
– |
{ |
179 |
– |
register int i, k; |
180 |
– |
|
181 |
– |
for (k=0; k < nsurf; k++) { |
182 |
– |
printf("\n%s polygon %s.%d.%d\n", material, name, n, k); |
183 |
– |
printf("0\n0\n12\n"); |
184 |
– |
for (i = 0; i < 4; i++) |
185 |
– |
printf("\t%18.12g\t%18.12g\t%18.12g\n", |
186 |
– |
baseblind[i][0][k], |
187 |
– |
baseblind[i][1][k], |
188 |
– |
baseblind[i][2][k] + height*(n-.5)/nslats); |
189 |
– |
} |
190 |
– |
} |
191 |
– |
|
192 |
– |
|
193 |
– |
printhead(ac, av) /* print command header */ |
194 |
– |
register int ac; |
195 |
– |
register char **av; |
196 |
– |
{ |
197 |
– |
putchar('#'); |
198 |
– |
while (ac--) { |
199 |
– |
putchar(' '); |
200 |
– |
fputs(*av++, stdout); |
201 |
– |
} |
202 |
– |
putchar('\n'); |
203 |
– |
} |