1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
– |
|
5 |
– |
/* Copyright (c) 1989 Regents of the University of California */ |
6 |
– |
|
4 |
|
/* |
5 |
|
* genworm.c - program to generate worms (strings with varying thickness). |
6 |
|
* |
12 |
|
*/ |
13 |
|
|
14 |
|
#include <stdio.h> |
15 |
< |
|
15 |
> |
#include <math.h> |
16 |
> |
#include "calcomp.h" |
17 |
|
#include "fvect.h" |
18 |
|
|
19 |
< |
#define XNAME "X_" /* x function name */ |
20 |
< |
#define YNAME "Y_" /* y function name */ |
21 |
< |
#define ZNAME "Z_" /* z function name */ |
22 |
< |
#define RNAME "R_" /* r function name */ |
19 |
> |
#define XNAME "X`SYS`" /* x function name */ |
20 |
> |
#define YNAME "Y`SYS`" /* y function name */ |
21 |
> |
#define ZNAME "Z`SYS`" /* z function name */ |
22 |
> |
#define RNAME "R`SYS`" /* r function name */ |
23 |
|
|
24 |
|
#define PI 3.14159265358979323846 |
25 |
|
|
28 |
– |
#define FTINY 1e-7 |
29 |
– |
|
26 |
|
#define max(a,b) ((a) > (b) ? (a) : (b)) |
27 |
|
|
28 |
|
|
29 |
< |
double funvalue(), l_hermite(), l_bezier(), l_bspline(), argument(); |
29 |
> |
double l_hermite(char *), l_bezier(char *), l_bspline(char *); |
30 |
> |
void quit(); |
31 |
|
|
32 |
|
|
33 |
|
main(argc, argv) |
34 |
|
int argc; |
35 |
|
char *argv[]; |
36 |
|
{ |
40 |
– |
extern long eclock; |
37 |
|
char stmp[256]; |
38 |
|
double t, f, lastr, r; |
39 |
|
FVECT lastp, p; |
40 |
|
int i, nseg; |
41 |
|
|
42 |
|
varset("PI", ':', PI); |
43 |
< |
funset("hermite", 5, l_hermite); |
44 |
< |
funset("bezier", 5, l_bezier); |
45 |
< |
funset("bspline", 5, l_bspline); |
43 |
> |
funset("hermite", 5, ':', l_hermite); |
44 |
> |
funset("bezier", 5, ':', l_bezier); |
45 |
> |
funset("bspline", 5, ':', l_bspline); |
46 |
|
|
47 |
|
if (argc < 8) |
48 |
|
goto userror; |
76 |
|
p[1] = funvalue(YNAME, 1, &t); |
77 |
|
p[2] = funvalue(ZNAME, 1, &t); |
78 |
|
r = funvalue(RNAME, 1, &t); |
79 |
< |
if (i) |
79 |
> |
if (i) { |
80 |
|
if (lastr <= r+FTINY && lastr >= r-FTINY) { |
81 |
|
printf("\n%s cylinder %s.c%d\n", |
82 |
|
argv[1], argv[2], i); |
103 |
|
f = f <= 0.0 ? 0.0 : sqrt(f); |
104 |
|
printf("%18.12g %18.12g\n", f*lastr, f*r); |
105 |
|
} |
106 |
+ |
} |
107 |
|
printf("\n%s sphere %s.s%d\n", argv[1], argv[2], i); |
108 |
|
printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n", |
109 |
|
p[0], p[1], p[2], r); |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
+ |
void |
124 |
|
eputs(msg) |
125 |
|
char *msg; |
126 |
|
{ |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
+ |
void |
132 |
|
wputs(msg) |
133 |
|
char *msg; |
134 |
|
{ |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
+ |
void |
140 |
|
quit(code) |
141 |
+ |
int code; |
142 |
|
{ |
143 |
|
exit(code); |
144 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
double |
161 |
< |
l_hermite() |
161 |
> |
l_hermite(char *nm) |
162 |
|
{ |
163 |
|
double t; |
164 |
|
|
171 |
|
|
172 |
|
|
173 |
|
double |
174 |
< |
l_bezier() |
174 |
> |
l_bezier(char *nm) |
175 |
|
{ |
176 |
|
double t; |
177 |
|
|
184 |
|
|
185 |
|
|
186 |
|
double |
187 |
< |
l_bspline() |
187 |
> |
l_bspline(char *nm) |
188 |
|
{ |
189 |
|
double t; |
190 |
|
|