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

Comparing ray/src/rt/p_func.c (file contents):
Revision 2.9 by greg, Wed Nov 15 18:02:53 2023 UTC vs.
Revision 2.12 by greg, Sun Jan 7 18:04:16 2024 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9  
10   #include  "ray.h"
11   #include  "func.h"
12 + #include  "random.h"
13   #include  "rtotypes.h"
14  
15   /*
# Line 30 | Line 31 | static const char      RCSid[] = "$Id$";
31   *  A spectral function is given as:
32   *
33   *      modifier specfunc name
34 < *      2+ sval filename xf
34 > *      2+ sfunc filename xf
35   *      0
36   *      2+ nmA nmB A3 ..
37   *
# Line 38 | Line 39 | static const char      RCSid[] = "$Id$";
39   *  can be found.  The list of real arguments can be accessed by
40   *  definitions in the file.  The xf is a transformation
41   *  to get from the original coordinates to the current coordinates.
42 < *  For the "specfunc" primitive, sval(nm) is a function of wavelength
42 > *  For the "specfunc" primitive, sfunc(nm) is a function of wavelength
43   *  and must be defined from nmA to nmB, and should average to 1 over
44   *  its range.
45   */
# Line 104 | Line 105 | p_specfunc(                    /* compute spectral pattern */
105          SCOLOR  scval;
106          double  wl, wlmin, wlmax, wlstep;
107          int     ns, i;
107        MFUNC   *mf;
108  
109          if ((m->oargs.nsargs < 2) | (m->oargs.nfargs < 2))
110                  objerror(m, USER, "bad # arguments");
# Line 122 | Line 122 | p_specfunc(                    /* compute spectral pattern */
122                  return(0);
123          }
124          wlstep = (wlmax - wlmin)/(double)MAXCSAMP;
125 <        if (wlstep*(5.*NCSAMP) < WLPART[0] - WLPART[3])
126 <                wlstep = (WLPART[0] - WLPART[3])/(5.*NCSAMP);
127 <        mf = getfunc(m, 1, 0, 0);
125 >        getfunc(m, 1, 0, 0);
126          setfunc(m, r);
127          errno = 0;
128          ns = (wlmax - wlmin)/wlstep + .1;
129          wl = wlmax - .5*wlstep;
130          for (i = ns; i-- > 0; wl -= wlstep) {
131 <                scsamp[i] = funvalue(m->oargs.sarg[0], 1, &wl);
131 >                double  ws = wl + 0.9*(.5-frandom())*wlstep;
132 >                scsamp[i] = funvalue(m->oargs.sarg[0], 1, &ws);
133                  if ((errno == EDOM) | (errno == ERANGE)) {
134                          objerror(m, WARNING, "compute error");
135                          return(0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines