--- ray/src/common/interp2d.h 2013/02/09 20:56:40 2.3 +++ ray/src/common/interp2d.h 2013/02/11 22:56:22 2.4 @@ -1,6 +1,6 @@ -/* RCSid $Id: interp2d.h,v 2.3 2013/02/09 20:56:40 greg Exp $ */ +/* RCSid $Id: interp2d.h,v 2.4 2013/02/11 22:56:22 greg Exp $ */ /* - * Header for interpolation of anisotropic values on 2-D plane. + * Header for interpolation of anisotropic samples on 2-D plane. * * G.Ward Feb 2013 */ @@ -12,16 +12,16 @@ extern "C" { #endif -#define NI2DSMF 0.42f /* minimal smoothing radius */ +#define NI2DSMF 0.42f /* minimal smoothing factor */ #define NI2DIR (2*4) /* # interpolation directions */ /* Data structure for interpolant */ typedef struct { int ns; /* number of sample positions */ - float rmin; /* minimum valid radius (default=.5) */ + float dmin; /* minimum diameter (default=1) */ float smf; /* smoothing factor (def=NI2DSMF) */ - unsigned short (*ra)[NI2DIR]; /* anisotropic radii (private) */ + unsigned short (*da)[NI2DIR]; /* anisotropic distances (private) */ float spt[1][2]; /* sample positions (extends struct) */ } INTERP2; @@ -43,6 +43,30 @@ extern void interp2_free(INTERP2 *ip); /* (Re)compute anisotropic basis function interpolant (normally automatic) */ extern int interp2_analyze(INTERP2 *ip); +/*************************************************************** + * Typical use is to allocate an INTERP2 struct and assign the + * spt[] array with the ordered sample locations in x & y. (The + * actual orientation of the axes is not important so long as + * the application is consistent.) During interpolation, either + * interp2_weights() is called to obtain a normalized weighting + * 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 together that interpolates the function at that + * location. Between the initial allocation call and the first + * weight evaluation, the dmin member may be adjusted to + * the distance under which samples will start to merge. If this + * parameter is later changed, interp2_analyze() should be called + * to recompute the interpolant. + * The smf member sets the smoothing factor for interpolation. + * The default setting of NI2DSMF produces near-optimal + * interpolation when well-separated sample values are known + * precisely. If a greater degree of mixing is desired, this + * paremter may be increased and it will affect the next call + * to interp2_weights() or interp2_topsamp(). + **************************************************************/ + #ifdef __cplusplus } #endif