ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/genworm.c
(Generate patch)

Comparing ray/src/gen/genworm.c (file contents):
Revision 1.1 by greg, Thu Feb 2 11:16:31 1989 UTC vs.
Revision 2.4 by greg, Sat Feb 22 02:07:23 2003 UTC

# Line 1 | Line 1
1 /*
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
4 + /*
5   *  genworm.c - program to generate worms (strings with varying thickness).
6   *
7   *      The program takes as input the functions of t for x, y,
# Line 13 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12   */
13  
14   #include  <stdio.h>
15 <
15 > #include  <math.h>
16   #include  "fvect.h"
17  
18 < #define  XNAME          "X_"                    /* x function name */
19 < #define  YNAME          "Y_"                    /* y function name */
20 < #define  ZNAME          "Z_"                    /* z function name */
21 < #define  RNAME          "R_"                    /* r function name */
18 > #define  XNAME          "X`SYS`"                /* x function name */
19 > #define  YNAME          "Y`SYS`"                /* y function name */
20 > #define  ZNAME          "Z`SYS`"                /* z function name */
21 > #define  RNAME          "R`SYS`"                /* r function name */
22  
23   #define  PI             3.14159265358979323846
24  
26 #define  FTINY          1e-7
27
25   #define  max(a,b)       ((a) > (b) ? (a) : (b))
26  
27  
28 < double  funvalue(), l_hermite(), argument();
28 > double  funvalue(), l_hermite(), l_bezier(), l_bspline(), argument();
29 > void  quit();
30  
31  
32   main(argc, argv)
33   int  argc;
34   char  *argv[];
35   {
36 +        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, NULL);
43 <        funset("hermite", 5, l_hermite);
42 >        varset("PI", ':', PI);
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;
49  
50          for (i = 8; i < argc; i++)
51                  if (!strcmp(argv[i], "-e"))
52 <                        scompile(NULL, argv[++i]);
52 >                        scompile(argv[++i], NULL, 0);
53                  else if (!strcmp(argv[i], "-f"))
54                          fcompile(argv[++i]);
55                  else
56                          goto userror;
57  
58          sprintf(stmp, "%s(t)=%s;", XNAME, argv[3]);
59 <        scompile(NULL, stmp);
59 >        scompile(stmp, NULL, 0);
60          sprintf(stmp, "%s(t)=%s;", YNAME, argv[4]);
61 <        scompile(NULL, stmp);
61 >        scompile(stmp, NULL, 0);
62          sprintf(stmp, "%s(t)=%s;", ZNAME, argv[5]);
63 <        scompile(NULL, stmp);
63 >        scompile(stmp, NULL, 0);
64          sprintf(stmp, "%s(t)=%s;", RNAME, argv[6]);
65 <        scompile(NULL, stmp);
65 >        scompile(stmp, NULL, 0);
66          nseg = atoi(argv[7]);
67          if (nseg <= 0)
68                  goto userror;
69  
70          printhead(argc, argv);
71 +        eclock = 0;
72  
73          for (i = 0; i <= nseg; i++) {
74                  t = (double)i/nseg;
# Line 117 | Line 119 | userror:
119   }
120  
121  
122 + void
123   eputs(msg)
124   char  *msg;
125   {
# Line 124 | Line 127 | char  *msg;
127   }
128  
129  
130 + void
131   wputs(msg)
132   char  *msg;
133   {
# Line 131 | Line 135 | char  *msg;
135   }
136  
137  
138 + void
139   quit(code)
140 + int  code;
141   {
142          exit(code);
143   }
# Line 160 | Line 166 | l_hermite()                    
166                  argument(2)*(-2.0*t+3.0)*t*t +
167                  argument(3)*((t-2.0)*t+1.0)*t +
168                  argument(4)*(t-1.0)*t*t );
169 + }
170 +
171 +
172 + double
173 + l_bezier()
174 + {
175 +        double  t;
176 +
177 +        t = argument(5);
178 +        return( argument(1) * (1.+t*(-3.+t*(3.-t))) +
179 +                argument(2) * 3.*t*(1.+t*(-2.+t)) +
180 +                argument(3) * 3.*t*t*(1.-t) +
181 +                argument(4) * t*t*t );
182 + }
183 +
184 +
185 + double
186 + l_bspline()
187 + {
188 +        double  t;
189 +
190 +        t = argument(5);
191 +        return( argument(1) * (1./6.+t*(-1./2.+t*(1./2.-1./6.*t))) +
192 +                argument(2) * (2./3.+t*t*(-1.+1./2.*t)) +
193 +                argument(3) * (1./6.+t*(1./2.+t*(1./2.-1./2.*t))) +
194 +                argument(4) * (1./6.*t*t*t) );
195   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines