ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/interp2d.h
Revision: 2.4
Committed: Mon Feb 11 22:56:22 2013 UTC (11 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.3: +29 -5 lines
Log Message:
Changed radius specification to diameter and added usage comment

File Contents

# Content
1 /* RCSid $Id: interp2d.h,v 2.3 2013/02/09 20:56:40 greg Exp $ */
2 /*
3 * Header for interpolation of anisotropic samples on 2-D plane.
4 *
5 * G.Ward Feb 2013
6 */
7
8 #ifndef _RAD_INTERP2D_H_
9 #define _RAD_INTERP2D_H_
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 #define NI2DSMF 0.42f /* minimal smoothing factor */
16
17 #define NI2DIR (2*4) /* # interpolation directions */
18
19 /* Data structure for interpolant */
20 typedef struct {
21 int ns; /* number of sample positions */
22 float dmin; /* minimum diameter (default=1) */
23 float smf; /* smoothing factor (def=NI2DSMF) */
24 unsigned short (*da)[NI2DIR]; /* anisotropic distances (private) */
25 float spt[1][2]; /* sample positions (extends struct) */
26 } INTERP2;
27
28 /* Allocate a new set of interpolation samples (caller assigns spt[] array) */
29 extern INTERP2 *interp2_alloc(int nsamps);
30
31 /* Resize interpolation array (caller must assign any new values) */
32 extern INTERP2 *interp2_realloc(INTERP2 *ip, int nsamps);
33
34 /* Assign full set of normalized weights to interpolate the given location */
35 extern int interp2_weights(float wtv[], INTERP2 *ip, double x, double y);
36
37 /* Get normalized weights and indexes for n best samples in descending order */
38 extern int interp2_topsamp(float wt[], int si[], const int n,
39 INTERP2 *ip, double x, double y);
40 /* Free interpolant */
41 extern void interp2_free(INTERP2 *ip);
42
43 /* (Re)compute anisotropic basis function interpolant (normally automatic) */
44 extern int interp2_analyze(INTERP2 *ip);
45
46 /***************************************************************
47 * Typical use is to allocate an INTERP2 struct and assign the
48 * spt[] array with the ordered sample locations in x & y. (The
49 * actual orientation of the axes is not important so long as
50 * the application is consistent.) During interpolation, either
51 * interp2_weights() is called to obtain a normalized weighting
52 * vector for all the samples, or interp2_topsamp() is called to
53 * get the most important N samples for the specified location.
54 * The weights (and indexes in the case of interp2_topsamp)
55 * are then used as coefficients for corresponding sample values
56 * in a vector sum together that interpolates the function at that
57 * location. Between the initial allocation call and the first
58 * weight evaluation, the dmin member may be adjusted to
59 * the distance under which samples will start to merge. If this
60 * parameter is later changed, interp2_analyze() should be called
61 * to recompute the interpolant.
62 * The smf member sets the smoothing factor for interpolation.
63 * The default setting of NI2DSMF produces near-optimal
64 * interpolation when well-separated sample values are known
65 * precisely. If a greater degree of mixing is desired, this
66 * paremter may be increased and it will affect the next call
67 * to interp2_weights() or interp2_topsamp().
68 **************************************************************/
69
70 #ifdef __cplusplus
71 }
72 #endif
73 #endif /* !_RAD_INTERP2D_H_ */