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

Comparing ray/src/cv/bsdfrep.c (file contents):
Revision 2.5 by greg, Wed Nov 7 03:04:23 2012 UTC vs.
Revision 2.9 by greg, Tue Nov 13 04:23:38 2012 UTC

# Line 56 | Line 56 | new_input_direction(double new_theta, double new_phi)
56                  new_theta = -new_theta;
57                  new_phi += 180.;
58          }
59 +        if ((theta_in_deg = new_theta) < 1.0)
60 +                return(1);              /* don't rely on phi near normal */
61          while (new_phi < 0)
62                  new_phi += 360.;
63          while (new_phi >= 360.)
# Line 64 | Line 66 | new_input_direction(double new_theta, double new_phi)
66                  single_plane_incident = (round(new_phi) == round(phi_in_deg));
67          else if (single_plane_incident < 0)
68                  single_plane_incident = 1;
67        theta_in_deg = new_theta;       /* assume it's OK */
69          phi_in_deg = new_phi;
70          if ((1. < new_phi) & (new_phi < 89.))
71                  inp_coverage |= INP_QUAD1;
# Line 177 | Line 178 | rev_rbf_symmetry(RBFNODE *rbf, int sym)
178                          rbf->rbfa[n].gy = grid_res-1 - rbf->rbfa[n].gy;
179   }
180  
181 + /* Rotate RBF to correspond to given incident vector */
182 + void
183 + rotate_rbf(RBFNODE *rbf, const FVECT invec)
184 + {
185 +        static const FVECT      vnorm = {.0, .0, 1.};
186 +        const double            phi = atan2(invec[1],invec[0]) -
187 +                                        atan2(rbf->invec[1],rbf->invec[0]);
188 +        FVECT                   outvec;
189 +        int                     pos[2];
190 +        int                     n;
191 +
192 +        for (n = rbf->nrbf; n-- > 0; ) {
193 +                ovec_from_pos(outvec, rbf->rbfa[n].gx, rbf->rbfa[n].gy);
194 +                spinvector(outvec, outvec, vnorm, phi);
195 +                pos_from_vec(pos, outvec);
196 +                rbf->rbfa[n].gx = pos[0];
197 +                rbf->rbfa[n].gy = pos[1];
198 +        }
199 +        VCOPY(rbf->invec, invec);
200 + }
201 +
202   /* Compute volume associated with Gaussian lobe */
203   double
204   rbf_volume(const RBFVAL *rbfp)
# Line 193 | Line 215 | ovec_from_pos(FVECT vec, int xpos, int ypos)
215          double  uv[2];
216          double  r2;
217          
218 <        SDsquare2disk(uv, (1./grid_res)*(xpos+.5), (1./grid_res)*(ypos+.5));
218 >        SDsquare2disk(uv, (xpos+.5)/grid_res, (ypos+.5)/grid_res);
219                                  /* uniform hemispherical projection */
220          r2 = uv[0]*uv[0] + uv[1]*uv[1];
221          vec[0] = vec[1] = sqrt(2. - r2);
# Line 219 | Line 241 | pos_from_vec(int pos[2], const FVECT vec)
241   double
242   eval_rbfrep(const RBFNODE *rp, const FVECT outvec)
243   {
244 <        double          res = .0;
244 >        double          res = 0;
245          const RBFVAL    *rbfp;
246          FVECT           odir;
247          double          sig2;
# Line 463 | Line 485 | load_bsdf_rep(FILE *ifp)
485                  rbfh.invec[0] = getflt(ifp);
486                  rbfh.invec[1] = getflt(ifp);
487                  rbfh.invec[2] = getflt(ifp);
488 +                if (normalize(rbfh.invec) == 0) {
489 +                        fprintf(stderr, "%s: zero incident vector\n", progname);
490 +                        return(0);
491 +                }
492                  rbfh.vtotal = getflt(ifp);
493                  rbfh.nrbf = getint(4, ifp);
494                  newrbf = (RBFNODE *)malloc(sizeof(RBFNODE) +
495                                          sizeof(RBFVAL)*(rbfh.nrbf-1));
496                  if (newrbf == NULL)
497                          goto memerr;
498 <                memcpy(newrbf, &rbfh, sizeof(RBFNODE));
498 >                memcpy(newrbf, &rbfh, sizeof(RBFNODE)-sizeof(RBFVAL));
499                  for (i = 0; i < rbfh.nrbf; i++) {
500                          newrbf->rbfa[i].peak = getflt(ifp);
501                          newrbf->rbfa[i].crad = getint(2, ifp) & 0xffff;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines