| 15 |
|
* rcurv - curvature radius of slats (up:>0;down:<0;flat:=0) |
| 16 |
|
*/ |
| 17 |
|
|
| 18 |
< |
#include <stdio.h> |
| 19 |
< |
#include <stdlib.h> |
| 18 |
> |
#include "rtio.h" |
| 19 |
> |
#include "paths.h" |
| 20 |
|
#include <math.h> |
| 21 |
– |
#include <string.h> |
| 21 |
|
|
| 22 |
+ |
#ifndef PI |
| 23 |
|
#define PI 3.14159265358979323846 |
| 24 |
< |
#define DELTA 10. /* MINIMAL SUSTAINED ANGLE IN DEGREES */ |
| 24 |
> |
#endif |
| 25 |
> |
#define DELTA 3. /* MINIMAL SUSTAINED ANGLE IN DEGREES */ |
| 26 |
|
|
| 27 |
|
double baseflat[4][3], baseblind[4][3][180]; |
| 28 |
|
double A[3],X[3]; |
| 33 |
|
|
| 34 |
|
static void makeflat(double w, double d, double a); |
| 35 |
|
static void printslat(int n); |
| 35 |
– |
static void printhead(register int ac, register char **av); |
| 36 |
|
|
| 37 |
– |
|
| 37 |
|
void |
| 38 |
|
makeflat( |
| 39 |
|
double w, |
| 66 |
|
int n |
| 67 |
|
) |
| 68 |
|
{ |
| 69 |
< |
register int i, k; |
| 69 |
> |
int i, k; |
| 70 |
|
|
| 71 |
|
for (k=0; k < nsurf; k++) { |
| 72 |
|
printf("\n%s polygon %s.%d.%d\n", material, name, n, k); |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
|
| 84 |
– |
void |
| 85 |
– |
printhead( /* print command header */ |
| 86 |
– |
register int ac, |
| 87 |
– |
register char **av |
| 88 |
– |
) |
| 89 |
– |
{ |
| 90 |
– |
putchar('#'); |
| 91 |
– |
while (ac--) { |
| 92 |
– |
putchar(' '); |
| 93 |
– |
fputs(*av++, stdout); |
| 94 |
– |
} |
| 95 |
– |
putchar('\n'); |
| 96 |
– |
} |
| 97 |
– |
|
| 98 |
– |
|
| 83 |
|
int |
| 84 |
|
main( |
| 85 |
|
int argc, |
| 86 |
|
char *argv[] |
| 87 |
|
) |
| 88 |
|
{ |
| 89 |
< |
double width, delem, depth, rcurv = 0.0, angle; |
| 89 |
> |
double width, delem, depth, rcurv = 0.0, mydelta, angle; |
| 90 |
|
double beta, gamma, theta, chi = 0; |
| 91 |
|
int i, j, k, l; |
| 92 |
|
|
| 100 |
|
height = atof(argv[5]); |
| 101 |
|
nslats = atoi(argv[6]); |
| 102 |
|
angle = atof(argv[7]); |
| 103 |
< |
if (argc == 10) |
| 103 |
> |
if (argc == 10) { |
| 104 |
|
if (!strcmp(argv[8], "-r")) |
| 105 |
|
rcurv = atof(argv[9]); |
| 106 |
|
else if (!strcmp(argv[8], "+r")) |
| 107 |
|
rcurv = -atof(argv[9]); |
| 108 |
|
else |
| 109 |
|
goto userr; |
| 110 |
< |
|
| 110 |
> |
} |
| 111 |
|
/* CURVED BLIND CALCULATION */ |
| 112 |
|
|
| 113 |
< |
if (rcurv != 0) { |
| 113 |
> |
if (rcurv != 0.) { |
| 114 |
|
|
| 115 |
|
/* BLINDS SUSTAINED ANGLE */ |
| 116 |
|
|
| 117 |
< |
theta = 2*asin(depth/(2*fabs(rcurv))); |
| 117 |
> |
theta = 2.*asin(depth/(2.*fabs(rcurv))); |
| 118 |
|
|
| 119 |
|
/* HOW MANY ELEMENTARY SURFACES SHOULD BE CALCULATED ? */ |
| 120 |
|
|
| 121 |
< |
nsurf = (int)(theta / ((PI/180.)*DELTA)) + 1; |
| 121 |
> |
nsurf = (int)(theta / ((PI/180.)*DELTA) + 0.99999); |
| 122 |
> |
|
| 123 |
> |
mydelta = (180./PI) * theta / nsurf; |
| 124 |
|
|
| 125 |
|
/* WHAT IS THE DEPTH OF THE ELEMENTARY SURFACES ? */ |
| 126 |
|
|
| 127 |
< |
delem = 2*fabs(rcurv)*sin((PI/180.)*(DELTA/2.)); |
| 127 |
> |
delem = 2.*fabs(rcurv)*sin((PI/180.)*(mydelta/2.)); |
| 128 |
|
|
| 129 |
|
beta = (PI-theta)/2.; |
| 130 |
|
gamma = beta -((PI/180.)*angle); |
| 133 |
|
|
| 134 |
|
if (rcurv < 0) { |
| 135 |
|
A[0]=fabs(rcurv)*cos(gamma); |
| 136 |
< |
A[0] *= -1; |
| 136 |
> |
A[0] *= -1.; |
| 137 |
|
A[1]=0.; |
| 138 |
|
A[2]=fabs(rcurv)*sin(gamma); |
| 139 |
|
} |
| 141 |
|
A[0]=fabs(rcurv)*cos(gamma+theta); |
| 142 |
|
A[1]=0.; |
| 143 |
|
A[2]=fabs(rcurv)*sin(gamma+theta); |
| 144 |
< |
A[2] *= -1; |
| 144 |
> |
A[2] *= -1.; |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
for (k=0; k < nsurf; k++) { |
| 148 |
|
if (rcurv < 0) { |
| 149 |
< |
chi=(PI/180.)*((180.-DELTA)/2.) - (gamma+(k*(PI/180.)*DELTA)); |
| 149 |
> |
chi=(PI/180.)*((180.-mydelta)/2.) - (gamma+(k*(PI/180.)*mydelta)); |
| 150 |
|
} |
| 151 |
|
if (rcurv > 0) { |
| 152 |
< |
chi=(PI-(gamma+theta)+(k*(PI/180.)*DELTA))-(PI/180.)* |
| 153 |
< |
((180.-DELTA)/2.); |
| 152 |
> |
chi=(PI-(gamma+theta)+(k*(PI/180.)*mydelta))-(PI/180.)* |
| 153 |
> |
((180.-mydelta)/2.); |
| 154 |
|
} |
| 155 |
|
makeflat(width, delem, chi); |
| 156 |
|
if (rcurv < 0.) { |
| 157 |
< |
X[0]=(-fabs(rcurv))*cos(gamma+(k*(PI/180.)*DELTA))-A[0]; |
| 157 |
> |
X[0]=(-fabs(rcurv))*cos(gamma+(k*(PI/180.)*mydelta))-A[0]; |
| 158 |
|
X[1]=0.; |
| 159 |
< |
X[2]=fabs(rcurv)*sin(gamma+(k*(PI/180.)*DELTA))-A[2]; |
| 159 |
> |
X[2]=fabs(rcurv)*sin(gamma+(k*(PI/180.)*mydelta))-A[2]; |
| 160 |
|
} |
| 161 |
|
if (rcurv > 0.) { |
| 162 |
< |
X[0]=fabs(rcurv)*cos(gamma+theta-(k*(PI/180.)*DELTA))-A[0]; |
| 162 |
> |
X[0]=fabs(rcurv)*cos(gamma+theta-(k*(PI/180.)*mydelta))-A[0]; |
| 163 |
|
X[1]=0.; |
| 164 |
< |
X[2]=(-fabs(rcurv))*sin(gamma+theta-(k*(PI/180.)*DELTA))-A[2]; |
| 164 |
> |
X[2]=(-fabs(rcurv))*sin(gamma+theta-(k*(PI/180.)*mydelta))-A[2]; |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
for (i=0; i < 4; i++) { |
| 174 |
|
|
| 175 |
|
/* FLAT BLINDS CALCULATION */ |
| 176 |
|
|
| 177 |
< |
if (rcurv == 0.) { |
| 177 |
> |
else { |
| 178 |
|
|
| 179 |
|
nsurf=1; |
| 180 |
|
makeflat(width,depth,angle*(PI/180.)); |
| 185 |
|
} |
| 186 |
|
} |
| 187 |
|
|
| 188 |
< |
printhead(argc, argv); |
| 189 |
< |
|
| 188 |
> |
fputs("# ", stdout); |
| 189 |
> |
printargs(argc, argv, stdout); |
| 190 |
> |
|
| 191 |
|
|
| 192 |
|
/* REPEAT THE BASIC CURVED OR FLAT SLAT TO GET THE OVERALL BLIND */ |
| 193 |
|
|