22 |
|
char *casemat = mycasemat; |
23 |
|
char *name = "clock"; |
24 |
|
|
25 |
< |
main(argc, argv) |
26 |
< |
int argc; |
27 |
< |
char *argv[]; |
28 |
< |
{ |
29 |
< |
int i, j; |
30 |
< |
double hour; |
31 |
< |
|
32 |
< |
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
33 |
< |
switch (argv[i][1]) { |
34 |
< |
case 'f': |
35 |
< |
facemat = argv[++i]; |
36 |
< |
break; |
37 |
< |
case 'c': |
38 |
< |
casemat = argv[++i]; |
39 |
< |
break; |
40 |
< |
case 'n': |
41 |
< |
name = argv[++i]; |
42 |
< |
break; |
43 |
< |
default: |
44 |
< |
goto userr; |
45 |
< |
} |
46 |
< |
if (i >= argc) |
47 |
< |
goto userr; |
48 |
< |
if (!isdigit(argv[i][0])) |
49 |
< |
goto userr; |
50 |
< |
for (j = 1; isdigit(argv[i][j]); j++) |
51 |
< |
; |
52 |
< |
if (argv[i][j] == ':') |
53 |
< |
hour = atoi(argv[i]) + atoi(argv[i]+j+1)/60.0; |
54 |
< |
else if (!argv[i][j] || argv[i][j] == '.') |
55 |
< |
hour = atof(argv[i]); |
56 |
< |
else |
57 |
< |
goto userr; |
58 |
< |
putchar('#'); /* print header */ |
59 |
< |
for (i = 0; i < argc; i++) { |
60 |
< |
putchar(' '); |
61 |
< |
fputs(argv[i], stdout); |
62 |
< |
} |
63 |
< |
putchar('\n'); |
64 |
< |
genmats(); /* print materials */ |
65 |
< |
genclock(); /* generate clock */ |
66 |
< |
genhands(hour); /* generate hands */ |
67 |
< |
exit(0); |
68 |
< |
userr: |
69 |
< |
fputs("Usage: ", stderr); |
70 |
< |
fputs(argv[0], stderr); |
71 |
< |
fputs(" [-f face_mat][-c case_mat][-n name] {HH:MM | HH.hh}\n", stderr); |
72 |
< |
exit(1); |
73 |
< |
} |
74 |
< |
|
75 |
< |
|
25 |
> |
static void |
26 |
|
genmats() /* put out our materials */ |
27 |
|
{ |
28 |
|
if (facemat == myfacemat) |
42 |
|
} |
43 |
|
|
44 |
|
|
45 |
+ |
static void |
46 |
|
genclock() /* put out clock body */ |
47 |
|
{ |
48 |
|
printf("\n%s ring %s.case_back\n", casemat, name); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
+ |
static void |
64 |
+ |
rvert(x, y, z, ang) /* print rotated vertex */ |
65 |
+ |
double x, y, z, ang; |
66 |
+ |
{ |
67 |
+ |
static double lastang=0, sa=0, ca=1; |
68 |
+ |
|
69 |
+ |
if (ang != lastang) { |
70 |
+ |
sa = sin(-ang); |
71 |
+ |
ca = cos(-ang); |
72 |
+ |
lastang = ang; |
73 |
+ |
} |
74 |
+ |
printf("%15.12g %15.12g %15.12g\n", x, y*ca-z*sa, z*ca+y*sa); |
75 |
+ |
} |
76 |
+ |
|
77 |
+ |
|
78 |
+ |
static void |
79 |
|
genhands(hour) /* generate correct hand positions */ |
80 |
|
double hour; |
81 |
|
{ |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
< |
rvert(x, y, z, ang) /* print rotated vertex */ |
104 |
< |
double x, y, z, ang; |
103 |
> |
int |
104 |
> |
main(argc, argv) |
105 |
> |
int argc; |
106 |
> |
char *argv[]; |
107 |
|
{ |
108 |
< |
static double lastang=0, sa=0, ca=1; |
108 |
> |
int i, j; |
109 |
> |
double hour; |
110 |
|
|
111 |
< |
if (ang != lastang) { |
112 |
< |
sa = sin(-ang); |
113 |
< |
ca = cos(-ang); |
114 |
< |
lastang = ang; |
111 |
> |
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
112 |
> |
switch (argv[i][1]) { |
113 |
> |
case 'f': |
114 |
> |
facemat = argv[++i]; |
115 |
> |
break; |
116 |
> |
case 'c': |
117 |
> |
casemat = argv[++i]; |
118 |
> |
break; |
119 |
> |
case 'n': |
120 |
> |
name = argv[++i]; |
121 |
> |
break; |
122 |
> |
default: |
123 |
> |
goto userr; |
124 |
> |
} |
125 |
> |
if (i >= argc) |
126 |
> |
goto userr; |
127 |
> |
if (!isdigit(argv[i][0])) |
128 |
> |
goto userr; |
129 |
> |
for (j = 1; isdigit(argv[i][j]); j++) |
130 |
> |
; |
131 |
> |
if (argv[i][j] == ':') |
132 |
> |
hour = atoi(argv[i]) + atoi(argv[i]+j+1)/60.0; |
133 |
> |
else if (!argv[i][j] || argv[i][j] == '.') |
134 |
> |
hour = atof(argv[i]); |
135 |
> |
else |
136 |
> |
goto userr; |
137 |
> |
putchar('#'); /* print header */ |
138 |
> |
for (i = 0; i < argc; i++) { |
139 |
> |
putchar(' '); |
140 |
> |
fputs(argv[i], stdout); |
141 |
|
} |
142 |
< |
printf("%15.12g %15.12g %15.12g\n", x, y*ca-z*sa, z*ca+y*sa); |
142 |
> |
putchar('\n'); |
143 |
> |
genmats(); /* print materials */ |
144 |
> |
genclock(); /* generate clock */ |
145 |
> |
genhands(hour); /* generate hands */ |
146 |
> |
exit(0); |
147 |
> |
userr: |
148 |
> |
fputs("Usage: ", stderr); |
149 |
> |
fputs(argv[0], stderr); |
150 |
> |
fputs(" [-f face_mat][-c case_mat][-n name] {HH:MM | HH.hh}\n", stderr); |
151 |
> |
exit(1); |
152 |
|
} |
153 |
+ |
|