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.1 by greg, Thu Feb 2 11:16:29 1989 UTC vs.
Revision 2.2 by greg, Fri Oct 2 16:11:28 1992 UTC

# Line 1 | Line 1
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   *  genrev.c - program to generate functions of rotation about z
9   *
10   *      The program takes as input the functions of t for z and r
# Line 13 | 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 26 | 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 41 | 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 58 | 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 96 | 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 154 | Line 161 | userror:
161   computen(nzp, nrp, z0, r0, z1, r1)              /* compute normal */
162   double  *nzp, *nrp, z0, r0, z1, r1;
163   {
157        extern double  sqrt();
164          double  dr, dz, len;
165  
166          dz = r0 - r1;                           /* right angle vector */
# Line 208 | Line 214 | l_hermite()                    
214                  argument(2)*(-2.0*t+3.0)*t*t +
215                  argument(3)*((t-2.0)*t+1.0)*t +
216                  argument(4)*(t-1.0)*t*t );
217 + }
218 +
219 +
220 + double
221 + l_bezier()
222 + {
223 +        double  t;
224 +
225 +        t = argument(5);
226 +        return( argument(1) * (1.+t*(-3.+t*(3.-t))) +
227 +                argument(2) * 3.*t*(1.+t*(-2.+t)) +
228 +                argument(3) * 3.*t*t*(1.-t) +
229 +                argument(4) * t*t*t );
230 + }
231 +
232 +
233 + double
234 + l_bspline()
235 + {
236 +        double  t;
237 +
238 +        t = argument(5);
239 +        return( argument(1) * (1./6.+t*(-1./2.+t*(1./2.-1./6.*t))) +
240 +                argument(2) * (2./3.+t*t*(-1.+1./2.*t)) +
241 +                argument(3) * (1./6.+t*(1./2.+t*(1./2.-1./2.*t))) +
242 +                argument(4) * (1./6.*t*t*t) );
243   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines