1 |
– |
/* |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
|
static char SCCSid[] = "$SunId$ LBL"; |
3 |
|
#endif |
4 |
+ |
|
5 |
+ |
/* Copyright (c) 1989 Regents of the University of California */ |
6 |
+ |
|
7 |
+ |
/* |
8 |
|
* genworm.c - program to generate worms (strings with varying thickness). |
9 |
|
* |
10 |
|
* The program takes as input the functions of t for x, y, |
30 |
|
#define max(a,b) ((a) > (b) ? (a) : (b)) |
31 |
|
|
32 |
|
|
33 |
< |
double funvalue(), l_hermite(), argument(); |
33 |
> |
double funvalue(), l_hermite(), l_bezier(), l_bspline(), argument(); |
34 |
|
|
35 |
|
|
36 |
|
main(argc, argv) |
44 |
|
|
45 |
|
varset("PI", PI, NULL); |
46 |
|
funset("hermite", 5, l_hermite); |
47 |
+ |
funset("bezier", 5, l_bezier); |
48 |
+ |
funset("bspline", 5, l_bspline); |
49 |
|
|
50 |
|
if (argc < 8) |
51 |
|
goto userror; |
164 |
|
argument(2)*(-2.0*t+3.0)*t*t + |
165 |
|
argument(3)*((t-2.0)*t+1.0)*t + |
166 |
|
argument(4)*(t-1.0)*t*t ); |
167 |
+ |
} |
168 |
+ |
|
169 |
+ |
|
170 |
+ |
double |
171 |
+ |
l_bezier() |
172 |
+ |
{ |
173 |
+ |
double t; |
174 |
+ |
|
175 |
+ |
t = argument(5); |
176 |
+ |
return( argument(1) * (1.+t*(-3.+t*(3.-t))) + |
177 |
+ |
argument(2) * 3.*t*(1.+t*(-2.+t)) + |
178 |
+ |
argument(3) * 3.*t*t*(1.-t) + |
179 |
+ |
argument(4) * t*t*t ); |
180 |
+ |
} |
181 |
+ |
|
182 |
+ |
|
183 |
+ |
double |
184 |
+ |
l_bspline() |
185 |
+ |
{ |
186 |
+ |
double t; |
187 |
+ |
|
188 |
+ |
t = argument(5); |
189 |
+ |
return( argument(1) * (1./6.+t*(-1./2.+t*(1./2.-1./6.*t))) + |
190 |
+ |
argument(2) * (2./3.+t*t*(-1.+1./2.*t)) + |
191 |
+ |
argument(3) * (1./6.+t*(1./2.+t*(1./2.-1./2.*t))) + |
192 |
+ |
argument(4) * (1./6.*t*t*t) ); |
193 |
|
} |