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

Comparing ray/src/gen/gensurf.c (file contents):
Revision 1.5 by greg, Fri Jan 19 00:03:08 1990 UTC vs.
Revision 1.8 by greg, Sat May 26 19:44:40 1990 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   *  gensurf.c - program to generate functional surfaces
9   *
# Line 34 | Line 34 | int  smooth = 0;               /* apply smoothing? */
34  
35   char  *modname, *surfname;
36  
37 < double  funvalue(), l_hermite(), argument();
37 > double  funvalue(), l_hermite(), l_bezier(), l_bspline(), argument();
38  
39   typedef struct {
40          FVECT  p;       /* vertex position */
# Line 52 | Line 52 | char  *argv[];
52  
53          varset("PI", PI);
54          funset("hermite", 5, l_hermite);
55 +        funset("bezier", 5, l_bezier);
56 +        funset("bspline", 5, l_bspline);
57  
58          if (argc < 8)
59                  goto userror;
# Line 217 | Line 219 | register POINT  *row;
219   int  siz;
220   {
221          double  st[2];
222 +        int  end;
223          register int  i;
224 <                                        /* compute one past each end */
224 >        
225 >        if (smooth) {
226 >                i = -1;                 /* compute one past each end */
227 >                end = siz+1;
228 >        } else {
229 >                if (s < -FTINY || s > 1.0+FTINY)
230 >                        return;
231 >                i = 0;
232 >                end = siz;
233 >        }
234          st[0] = s;
235 <        for (i = -1; i <= siz+1; i++) {
235 >        while (i <= end) {
236                  st[1] = (double)i/siz;
237                  row[i].p[0] = funvalue(XNAME, 2, st);
238                  row[i].p[1] = funvalue(YNAME, 2, st);
239                  row[i].p[2] = funvalue(ZNAME, 2, st);
240 +                i++;
241          }
242   }
243  
# Line 415 | Line 428 | l_hermite()                    
428                  argument(2)*(-2.0*t+3.0)*t*t +
429                  argument(3)*((t-2.0)*t+1.0)*t +
430                  argument(4)*(t-1.0)*t*t );
431 + }
432 +
433 +
434 + double
435 + l_bezier()
436 + {
437 +        double  t;
438 +
439 +        t = argument(5);
440 +        return( argument(1) * (1.+t*(-3.+t*(3.-t))) +
441 +                argument(2) * 3.*t*(1.+t*(-2.+t)) +
442 +                argument(3) * 3.*t*t*(1.-t) +
443 +                argument(4) * t*t*t );
444 + }
445 +
446 +
447 + double
448 + l_bspline()
449 + {
450 +        double  t;
451 +
452 +        t = argument(5);
453 +        return( argument(1) * (1./6.+t*(-1./2.+t*(1./2.-1./6.*t))) +
454 +                argument(2) * (2./3.+t*t*(-1.+1./2.*t)) +
455 +                argument(3) * (1./6.+t*(1./2.+t*(1./2.-1./2.*t))) +
456 +                argument(4) * (1./6.*t*t*t) );
457   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines