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

Comparing ray/src/common/bsdf_m.c (file contents):
Revision 3.31 by greg, Mon Apr 6 16:00:15 2015 UTC vs.
Revision 3.32 by greg, Wed Apr 8 02:41:02 2015 UTC

# Line 132 | Line 132 | SDfreeMatrix(void *ptr)
132          free(ptr);
133   }
134  
135 + /* compute square of real value */
136 + static double sq(double x) { return x*x; }
137 +
138   /* Get vector for this angle basis index (front exiting) */
139   int
140   fo_getvec(FVECT v, double ndxr, void *p)
# Line 141 | Line 144 | fo_getvec(FVECT v, double ndxr, void *p)
144          double          randX = ndxr - ndx;
145          double          rx[2];
146          int             li;
147 <        double          pol, azi, d;
147 >        double          azi, d;
148          
149          if ((ndxr < 0) | (ndx >= ab->nangles))
150                  return RC_FAIL;
151          for (li = 0; ndx >= ab->lat[li].nphis; li++)
152                  ndx -= ab->lat[li].nphis;
153          SDmultiSamp(rx, 2, randX);
154 <        pol = M_PI/180.*( (1.-rx[0])*ab->lat[li].tmin +
155 <                                rx[0]*ab->lat[li+1].tmin );
154 >        d = (1. - randX)*sq(cos(M_PI/180.*ab->lat[li].tmin)) +
155 >                randX*sq(cos(M_PI/180.*ab->lat[li+1].tmin));
156 >        v[2] = d = sqrt(d);     /* cos(pol) */
157          azi = 2.*M_PI*(ndx + rx[1] - .5)/ab->lat[li].nphis;
154        v[2] = d = cos(pol);
158          d = sqrt(1. - d*d);     /* sin(pol) */
159          v[0] = cos(azi)*d;
160          v[1] = sin(azi)*d;
# Line 183 | Line 186 | fo_getndx(const FVECT v, void *p)
186                  ndx += ab->lat[li].nphis;
187          return ndx;
188   }
186
187 /* compute square of real value */
188 static double sq(double x) { return x*x; }
189  
190   /* Get projected solid angle for this angle basis index (universal) */
191   double

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines