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

Comparing ray/src/common/ccolor.c (file contents):
Revision 3.11 by greg, Thu Apr 13 00:42:01 2017 UTC vs.
Revision 3.12 by greg, Thu Jan 4 01:55:42 2024 UTC

# Line 135 | Line 135 | c_sset(C_COLOR *clr, double wlmin, double wlmax, const
135          if ((nwl <= 1) | (spec == NULL) | (wlmin >= C_CMAXWL) |
136                          (wlmax <= C_CMINWL) | (wlmin >= wlmax))
137                  return(0.);
138 <        wlstep = (wlmax - wlmin)/(nwl-1);
138 >        wlstep = (wlmax - wlmin)/(nwl-1.);
139          while (wlmin < C_CMINWL) {
140                  wlmin += wlstep;
141                  --nwl; ++spec;
# Line 184 | Line 184 | c_sset(C_COLOR *clr, double wlmin, double wlmax, const
184                  if ((wl < wlmin) | (wl > wlmax))
185                          clr->ssamp[i] = 0;
186                  else {
187 <                        while (wl0 + wlstep < wl+1e-7) {
187 >                        while (wl0 + wlstep < wl+.01) {
188                                  wl0 += wlstep;
189                                  pos++;
190                          }
191 <                        if ((wl+1e-7 >= wl0) & (wl-1e-7 <= wl0))
191 >                        if ((wl+.01 >= wl0) & (wl-.01 <= wl0))
192                                  clr->ssamp[i] = scale*va[pos] + frand();
193                          else            /* interpolate if necessary */
194                                  clr->ssamp[i] = frand() + scale / wlstep *
# Line 200 | Line 200 | c_sset(C_COLOR *clr, double wlmin, double wlmax, const
200          return(yval);
201   }
202  
203 +
204 + /* check if colors are equivalent */
205 + int
206 + c_equiv(C_COLOR *c1, C_COLOR *c2)
207 + {
208 +        long    thresh;
209 +        int     i;
210 +
211 +        if (c1 == c2)
212 +                return(1);
213 +        c_ccvt(c1, C_CSXY);             /* first check chromaticities */
214 +        c_ccvt(c2, C_CSXY);
215 +        if (fabs(c1->cx - c2->cx) + fabs(c1->cy - c2->cy) > .015)
216 +                return(0);              /* mismatch means definitely different */
217 +        if (c1->flags & c2->flags & C_CDXY)
218 +                return(1);              /* done if both defined as (x,y) */
219 +        c_ccvt(c1, C_CSSPEC);           /* else compare spectra */
220 +        c_ccvt(c2, C_CSSPEC);
221 +        thresh = C_CMAXV/200*(c1->ssum + c2->ssum);
222 +        for (i = 0; i < C_CNSS; i++)
223 +                if (labs(c1->ssamp[i]*c2->ssum - c2->ssamp[i]*c1->ssum) > thresh)
224 +                        return(0);
225 +        return(1);
226 + }
227 +
228 +
229   /* check if color is grey */
230   int
231   c_isgrey(C_COLOR *clr)
# Line 220 | Line 246 | c_ccvt(C_COLOR *clr, int fl)
246          double  x, y, z;
247          int     i;
248  
249 <        fl &= ~clr->flags;                      /* ignore what's done */
250 <        if (!fl)                                /* everything's done! */
249 >        fl &= ~clr->flags;              /* ignore what's done */
250 >        if (!fl)                        /* everything's done! */
251                  return;
252          if (!(clr->flags & (C_CSXY|C_CSSPEC))) {
253 <                *clr = c_dfcolor;               /* nothing was set! */
253 >                *clr = c_dfcolor;       /* nothing was set! */
254                  return;
255          }
256          if (fl & C_CSXY) {              /* cspec -> cxy */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines