| 1 |
< |
/* |
| 1 |
> |
/* Copyright (c) 1989 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 5 |
|
#endif |
| 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(), 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 |
|
|
| 49 |
|
if (argc < 8) |
| 50 |
|
goto userror; |
| 163 |
|
argument(2)*(-2.0*t+3.0)*t*t + |
| 164 |
|
argument(3)*((t-2.0)*t+1.0)*t + |
| 165 |
|
argument(4)*(t-1.0)*t*t ); |
| 166 |
+ |
} |
| 167 |
+ |
|
| 168 |
+ |
|
| 169 |
+ |
double |
| 170 |
+ |
l_bezier() |
| 171 |
+ |
{ |
| 172 |
+ |
double t; |
| 173 |
+ |
|
| 174 |
+ |
t = argument(5); |
| 175 |
+ |
return( argument(1) * (1.+t*(-3.+t*(3.-t))) + |
| 176 |
+ |
argument(2) * 3.*t*(1.+t*(-2.+t)) + |
| 177 |
+ |
argument(3) * 3.*t*t*(1.-t) + |
| 178 |
+ |
argument(4) * t*t*t ); |
| 179 |
|
} |