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

Comparing ray/src/gen/genrev.c (file contents):
Revision 1.2 by greg, Sun Sep 10 16:45:14 1989 UTC vs.
Revision 2.3 by greg, Thu Nov 18 09:33:01 1993 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1989 Regents of the University of California */
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   *  genrev.c - program to generate functions of rotation about z
9   *
# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   */
16  
17   #include  <stdio.h>
18 + #include  <math.h>
19  
20 < #define  ZNAME          "Z_"                    /* z function name */
21 < #define  RNAME          "R_"                    /* r 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  
# Line 28 | Line 29 | static char SCCSid[] = "$SunId$ LBL";
29   #define  UP             04
30   #define  DOWN           010
31  
32 < double  funvalue(), l_hermite(), argument();
32 > double  funvalue(), l_hermite(), l_bezier(), l_bspline(), argument();
33  
34  
35   main(argc, argv)
36   int  argc;
37   char  *argv[];
38   {
39 +        extern long     eclock;
40          char  stmp[256];
41          char  *modname;
42          int  smooth = 0;
# Line 43 | Line 45 | char  *argv[];
45          int  i, nseg;
46          int  orient;
47  
48 <        varset("PI", PI);
49 <        funset("hermite", 5, l_hermite);
48 >        varset("PI", ':', PI);
49 >        funset("hermite", 5, ':', l_hermite);
50 >        funset("bezier", 5, ':', l_bezier);
51 >        funset("bspline", 5, ':', l_bspline);
52  
53          if (argc < 6)
54                  goto userror;
55  
56          for (i = 6; i < argc; i++)
57                  if (!strcmp(argv[i], "-e"))
58 <                        scompile(NULL, argv[++i]);
58 >                        scompile(argv[++i], NULL, 0);
59                  else if (!strcmp(argv[i], "-f"))
60                          fcompile(argv[++i]);
61                  else if (!strcmp(argv[i], "-s"))
# Line 60 | Line 64 | char  *argv[];
64                          goto userror;
65  
66          sprintf(stmp, "%s(t)=%s;", ZNAME, argv[3]);
67 <        scompile(NULL, stmp);
67 >        scompile(stmp, NULL, 0);
68          sprintf(stmp, "%s(t)=%s;", RNAME, argv[4]);
69 <        scompile(NULL, stmp);
69 >        scompile(stmp, NULL, 0);
70          nseg = atoi(argv[5]);
71          if (nseg <= 0)
72                  goto userror;
73 <        modname = smooth ? "phong" : argv[1];
73 >        modname = smooth ? "Phong" : argv[1];
74  
75          printhead(argc, argv);
76 +        eclock = 0;
77  
78          lastnz = lastnr = 0.0;
79          t = 0.0;
# Line 98 | Line 103 | char  *argv[];
103                  if (!orient)
104                          goto endfor;
105                  if (smooth) {
106 <                        printf("\n%s texfunc phong\n", argv[1]);
106 >                        printf("\n%s texfunc Phong\n", argv[1]);
107                          printf("4 rev_dx rev_dy rev_dz rev.cal\n");
108                          printf("0\n4\n");
109                          if (orient&(UP|DOWN)) {
# Line 156 | Line 161 | userror:
161   computen(nzp, nrp, z0, r0, z1, r1)              /* compute normal */
162   double  *nzp, *nrp, z0, r0, z1, r1;
163   {
159        extern double  sqrt();
164          double  dr, dz, len;
165  
166          dz = r0 - r1;                           /* right angle vector */
# Line 182 | Line 186 | char  *msg;
186  
187  
188   quit(code)
189 + int  code;
190   {
191          exit(code);
192   }
# Line 210 | Line 215 | l_hermite()                    
215                  argument(2)*(-2.0*t+3.0)*t*t +
216                  argument(3)*((t-2.0)*t+1.0)*t +
217                  argument(4)*(t-1.0)*t*t );
218 + }
219 +
220 +
221 + double
222 + l_bezier()
223 + {
224 +        double  t;
225 +
226 +        t = argument(5);
227 +        return( argument(1) * (1.+t*(-3.+t*(3.-t))) +
228 +                argument(2) * 3.*t*(1.+t*(-2.+t)) +
229 +                argument(3) * 3.*t*t*(1.-t) +
230 +                argument(4) * t*t*t );
231 + }
232 +
233 +
234 + double
235 + l_bspline()
236 + {
237 +        double  t;
238 +
239 +        t = argument(5);
240 +        return( argument(1) * (1./6.+t*(-1./2.+t*(1./2.-1./6.*t))) +
241 +                argument(2) * (2./3.+t*t*(-1.+1./2.*t)) +
242 +                argument(3) * (1./6.+t*(1./2.+t*(1./2.-1./2.*t))) +
243 +                argument(4) * (1./6.*t*t*t) );
244   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines