--- ray/src/common/interp2d.h 2013/02/11 23:33:35 2.5 +++ ray/src/common/interp2d.h 2013/02/14 19:57:10 2.7 @@ -1,4 +1,4 @@ -/* RCSid $Id: interp2d.h,v 2.5 2013/02/11 23:33:35 greg Exp $ */ +/* RCSid $Id: interp2d.h,v 2.7 2013/02/14 19:57:10 greg Exp $ */ /* * Header for interpolation of anisotropic samples on 2-D plane. * @@ -15,13 +15,20 @@ extern "C" { #define NI2DSMF 0.42f /* minimal smoothing factor */ #define NI2DIR (2*4) /* # interpolation directions */ +#define NI2DIM 16 /* size of black flag array */ /* Data structure for interpolant */ typedef struct { int ns; /* number of sample positions */ float dmin; /* minimum diameter (default=1) */ float smf; /* smoothing factor (def=NI2DSMF) */ - unsigned short (*da)[NI2DIR]; /* anisotropic distances (private) */ + float smin[2]; /* sample minima */ + float smul[2]; /* NI2DIM/(smax-smin) */ + float grid2; /* twice grid diameter squared */ + struct interp2_samp { + unsigned short dia[NI2DIR]; + unsigned short blkflg[NI2DIM]; + } *da; /* direction array (private) */ float spt[1][2]; /* sample positions (extends struct) */ } INTERP2; @@ -49,6 +56,9 @@ extern void interp2_free(INTERP2 *ip); /* (Re)compute anisotropic basis function interpolant (normally automatic) */ extern int interp2_analyze(INTERP2 *ip); +/* Compute unnormalized weight for a position relative to a sample */ +double interp2_wti(INTERP2 *ip, const int i, double x, double y); + /*************************************************************** * Typical use is to allocate an INTERP2 struct and assign the * spt[] array with the ordered sample locations in x & y. (The @@ -58,19 +68,19 @@ extern int interp2_analyze(INTERP2 *ip); * vector for all the samples, or interp2_topsamp() is called to * get the most important N samples for the specified location. * The weights (and indexes in the case of interp2_topsamp) - * are then used as coefficients for corresponding sample values - * in a vector sum that interpolates the function at that - * location. + * are then used as coefficients for corresponding sample + * values in a vector sum that interpolates the function at + * that location. * The minimum distance between sample positions defaults to 1.0. - * Values spaced closer than this will be merged (averaged). The - * interp2_spacing() call may be used to alter this member, + * Values spaced closer than this will be merged/averaged. + * The interp2_spacing() call may be used to alter this distance, * causing the interpolant to be recalculated during the - * next call to either of the sampling functions. + * next call to the sampling functions. * The default smoothing factor NI2DSMF provides near-optimal * interpolation when well-separated values are known - * precisely. Increase this setting by a factor > 1.0 + * precisely. Increase this setting by a factor > 1 * with the interp2_smooth() call if greater mixing is desired. - * A call of interp2_smooth(ip,0.0) resets to the minimum + * A call of interp2_smooth(ip,0) resets to the minimum * default. It is not possible to "sharpen" the data. **************************************************************/