12 |
|
*/ |
13 |
|
|
14 |
|
#include <stdlib.h> |
15 |
– |
#include <stdio.h> |
16 |
– |
#include <string.h> |
15 |
|
#include <math.h> |
16 |
|
|
17 |
+ |
#include "rtio.h" |
18 |
|
#include "rterror.h" |
19 |
+ |
#include "resolu.h" |
20 |
|
#include "calcomp.h" |
21 |
|
|
22 |
|
#define ZNAME "Z`SYS`" /* z function name */ |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
– |
void |
50 |
– |
eputs(msg) |
51 |
– |
char *msg; |
52 |
– |
{ |
53 |
– |
fputs(msg, stderr); |
54 |
– |
} |
55 |
– |
|
56 |
– |
|
57 |
– |
void |
58 |
– |
wputs(msg) |
59 |
– |
char *msg; |
60 |
– |
{ |
61 |
– |
eputs(msg); |
62 |
– |
} |
63 |
– |
|
64 |
– |
|
65 |
– |
void |
66 |
– |
quit(code) |
67 |
– |
int code; |
68 |
– |
{ |
69 |
– |
exit(code); |
70 |
– |
} |
71 |
– |
|
72 |
– |
|
73 |
– |
void |
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 |
– |
|
49 |
|
double |
50 |
|
l_hermite(char *nm) |
51 |
|
{ |
98 |
|
int i, nseg; |
99 |
|
int orient; |
100 |
|
|
101 |
+ |
esupport |= E_VARIABLE|E_FUNCTION|E_RCONST; |
102 |
+ |
esupport &= ~(E_OUTCHAN|E_INCHAN); |
103 |
|
varset("PI", ':', PI); |
104 |
|
funset("hermite", 5, ':', l_hermite); |
105 |
|
funset("bezier", 5, ':', l_bezier); |
111 |
|
for (i = 6; i < argc; i++) |
112 |
|
if (!strcmp(argv[i], "-e")) |
113 |
|
scompile(argv[++i], NULL, 0); |
114 |
< |
else if (!strcmp(argv[i], "-f")) |
115 |
< |
fcompile(argv[++i]); |
116 |
< |
else if (!strcmp(argv[i], "-s")) |
114 |
> |
else if (!strcmp(argv[i], "-f")) { |
115 |
> |
char *fpath = getpath(argv[++i], getrlibpath(), 0); |
116 |
> |
if (fpath == NULL) { |
117 |
> |
fprintf(stderr, "%s: cannot find file '%s'\n", |
118 |
> |
argv[0], argv[i]); |
119 |
> |
quit(1); |
120 |
> |
} |
121 |
> |
fcompile(fpath); |
122 |
> |
} else if (!strcmp(argv[i], "-s")) |
123 |
|
smooth = 1; |
124 |
|
else |
125 |
|
goto userror; |
128 |
|
scompile(stmp, NULL, 0); |
129 |
|
sprintf(stmp, "%s(t)=%s;", RNAME, argv[4]); |
130 |
|
scompile(stmp, NULL, 0); |
131 |
< |
nseg = atoi(argv[5]); |
131 |
> |
nseg = eval(argv[5]) + .5; |
132 |
|
if (nseg <= 0) |
133 |
|
goto userror; |
134 |
|
modname = smooth ? "Phong" : argv[1]; |
135 |
|
|
136 |
< |
printhead(argc, argv); |
137 |
< |
eclock = 0; |
136 |
> |
fputs("# ", stdout); |
137 |
> |
printargs(argc, argv, stdout); |
138 |
> |
doptimize(1); |
139 |
> |
eclock++; |
140 |
|
|
141 |
|
lastnz = lastnr = 0.0; |
142 |
|
t = 0.0; |
171 |
|
printf("0\n4\n"); |
172 |
|
if (orient&(UP|DOWN)) { |
173 |
|
t = (nextnz - lastnz)/(z - lastz); |
174 |
< |
printf("\t%15.9g\t%15.9g\n", |
174 |
> |
printf("\t%18.12g\t%18.12g\n", |
175 |
|
t, lastnz - t*lastz); |
176 |
|
} else |
177 |
|
printf("\t0\t%d\n", orient&IN ? 1 : -1); |
178 |
|
if (orient&(OUT|IN)) { |
179 |
|
t = (nextnr - lastnr)/(r - lastr); |
180 |
< |
printf("\t%15.9g\t%15.9g\n", |
180 |
> |
printf("\t%18.12g\t%18.12g\n", |
181 |
|
t, lastnr - t*lastr); |
182 |
|
} else |
183 |
|
printf("\t0\t%d\n", orient&UP ? 1 : -1); |
187 |
|
orient&DOWN ? "tube" : "cylinder", |
188 |
|
argv[2], i); |
189 |
|
printf("0\n0\n7\n"); |
190 |
< |
printf("\t0\t0\t%15.9g\n", lastz); |
191 |
< |
printf("\t0\t0\t%15.9g\n", z); |
192 |
< |
printf("\t%15.9g\n", r); |
190 |
> |
printf("\t0\t0\t%18.12g\n", lastz); |
191 |
> |
printf("\t0\t0\t%18.12g\n", z); |
192 |
> |
printf("\t%18.12g\n", r); |
193 |
|
} else if (!(orient&(UP|DOWN))) { |
194 |
|
printf("\n%s ring %s.%d\n", modname, argv[2], i); |
195 |
|
printf("0\n0\n8\n"); |
196 |
< |
printf("\t0\t0\t%15.9g\n", z); |
197 |
< |
printf("\t0\t0\t%15.9g\n", orient&IN ? 1.0 : -1.0); |
198 |
< |
printf("\t%15.9g\t%15.9g\n", lastr, r); |
196 |
> |
printf("\t0\t0\t%18.12g\n", z); |
197 |
> |
printf("\t0\t0\t%18.12g\n", orient&IN ? 1.0 : -1.0); |
198 |
> |
printf("\t%18.12g\t%18.12g\n", lastr, r); |
199 |
|
} else { |
200 |
|
printf("\n%s %s %s.%d\n", modname, |
201 |
|
orient&DOWN ? "cup" : "cone", |
202 |
|
argv[2], i); |
203 |
|
printf("0\n0\n8\n"); |
204 |
< |
printf("\t0\t0\t%15.9g\n", lastz); |
205 |
< |
printf("\t0\t0\t%15.9g\n", z); |
206 |
< |
printf("\t%15.9g\t%15.9g\n", lastr, r); |
204 |
> |
printf("\t0\t0\t%18.12g\n", lastz); |
205 |
> |
printf("\t0\t0\t%18.12g\n", z); |
206 |
> |
printf("\t%18.12g\t%18.12g\n", lastr, r); |
207 |
|
} |
208 |
|
endfor: |
209 |
|
lastz = z; lastr = r; |