1 |
– |
/* |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
+ |
/* |
5 |
|
* genrev.c - program to generate functions of rotation about z |
6 |
|
* |
7 |
|
* The program takes as input the functions of t for z and r |
12 |
|
*/ |
13 |
|
|
14 |
|
#include <stdio.h> |
15 |
+ |
#include <math.h> |
16 |
|
|
17 |
< |
#define ZNAME "Z_" /* z function name */ |
18 |
< |
#define RNAME "R_" /* r function name */ |
17 |
> |
#define ZNAME "Z`SYS`" /* z function name */ |
18 |
> |
#define RNAME "R`SYS`" /* r function name */ |
19 |
|
|
20 |
|
#define PI 3.14159265358979323846 |
21 |
|
|
26 |
|
#define UP 04 |
27 |
|
#define DOWN 010 |
28 |
|
|
29 |
< |
double funvalue(), l_hermite(), argument(); |
29 |
> |
double funvalue(), l_hermite(), l_bezier(), l_bspline(), argument(); |
30 |
|
|
31 |
+ |
void quit(), eputs(), wputs(); |
32 |
|
|
33 |
+ |
|
34 |
|
main(argc, argv) |
35 |
|
int argc; |
36 |
|
char *argv[]; |
37 |
|
{ |
38 |
+ |
extern long eclock; |
39 |
|
char stmp[256]; |
40 |
|
char *modname; |
41 |
|
int smooth = 0; |
44 |
|
int i, nseg; |
45 |
|
int orient; |
46 |
|
|
47 |
< |
varset("PI", PI); |
48 |
< |
funset("hermite", 5, l_hermite); |
47 |
> |
varset("PI", ':', PI); |
48 |
> |
funset("hermite", 5, ':', l_hermite); |
49 |
> |
funset("bezier", 5, ':', l_bezier); |
50 |
> |
funset("bspline", 5, ':', l_bspline); |
51 |
|
|
52 |
|
if (argc < 6) |
53 |
|
goto userror; |
54 |
|
|
55 |
|
for (i = 6; i < argc; i++) |
56 |
|
if (!strcmp(argv[i], "-e")) |
57 |
< |
scompile(NULL, argv[++i]); |
57 |
> |
scompile(argv[++i], NULL, 0); |
58 |
|
else if (!strcmp(argv[i], "-f")) |
59 |
|
fcompile(argv[++i]); |
60 |
|
else if (!strcmp(argv[i], "-s")) |
63 |
|
goto userror; |
64 |
|
|
65 |
|
sprintf(stmp, "%s(t)=%s;", ZNAME, argv[3]); |
66 |
< |
scompile(NULL, stmp); |
66 |
> |
scompile(stmp, NULL, 0); |
67 |
|
sprintf(stmp, "%s(t)=%s;", RNAME, argv[4]); |
68 |
< |
scompile(NULL, stmp); |
68 |
> |
scompile(stmp, NULL, 0); |
69 |
|
nseg = atoi(argv[5]); |
70 |
|
if (nseg <= 0) |
71 |
|
goto userror; |
72 |
< |
modname = smooth ? "phong" : argv[1]; |
72 |
> |
modname = smooth ? "Phong" : argv[1]; |
73 |
|
|
74 |
|
printhead(argc, argv); |
75 |
+ |
eclock = 0; |
76 |
|
|
77 |
|
lastnz = lastnr = 0.0; |
78 |
|
t = 0.0; |
102 |
|
if (!orient) |
103 |
|
goto endfor; |
104 |
|
if (smooth) { |
105 |
< |
printf("\n%s texfunc phong\n", argv[1]); |
105 |
> |
printf("\n%s texfunc Phong\n", argv[1]); |
106 |
|
printf("4 rev_dx rev_dy rev_dz rev.cal\n"); |
107 |
|
printf("0\n4\n"); |
108 |
|
if (orient&(UP|DOWN)) { |
160 |
|
computen(nzp, nrp, z0, r0, z1, r1) /* compute normal */ |
161 |
|
double *nzp, *nrp, z0, r0, z1, r1; |
162 |
|
{ |
157 |
– |
extern double sqrt(); |
163 |
|
double dr, dz, len; |
164 |
|
|
165 |
|
dz = r0 - r1; /* right angle vector */ |
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
+ |
void |
174 |
|
eputs(msg) |
175 |
|
char *msg; |
176 |
|
{ |
178 |
|
} |
179 |
|
|
180 |
|
|
181 |
+ |
void |
182 |
|
wputs(msg) |
183 |
|
char *msg; |
184 |
|
{ |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
+ |
void |
190 |
|
quit(code) |
191 |
+ |
int code; |
192 |
|
{ |
193 |
|
exit(code); |
194 |
|
} |
217 |
|
argument(2)*(-2.0*t+3.0)*t*t + |
218 |
|
argument(3)*((t-2.0)*t+1.0)*t + |
219 |
|
argument(4)*(t-1.0)*t*t ); |
220 |
+ |
} |
221 |
+ |
|
222 |
+ |
|
223 |
+ |
double |
224 |
+ |
l_bezier() |
225 |
+ |
{ |
226 |
+ |
double t; |
227 |
+ |
|
228 |
+ |
t = argument(5); |
229 |
+ |
return( argument(1) * (1.+t*(-3.+t*(3.-t))) + |
230 |
+ |
argument(2) * 3.*t*(1.+t*(-2.+t)) + |
231 |
+ |
argument(3) * 3.*t*t*(1.-t) + |
232 |
+ |
argument(4) * t*t*t ); |
233 |
+ |
} |
234 |
+ |
|
235 |
+ |
|
236 |
+ |
double |
237 |
+ |
l_bspline() |
238 |
+ |
{ |
239 |
+ |
double t; |
240 |
+ |
|
241 |
+ |
t = argument(5); |
242 |
+ |
return( argument(1) * (1./6.+t*(-1./2.+t*(1./2.-1./6.*t))) + |
243 |
+ |
argument(2) * (2./3.+t*t*(-1.+1./2.*t)) + |
244 |
+ |
argument(3) * (1./6.+t*(1./2.+t*(1./2.-1./2.*t))) + |
245 |
+ |
argument(4) * (1./6.*t*t*t) ); |
246 |
|
} |