PLplot
5.10.0
|
00001 //-------------------------------------------------------------------------- 00002 // 00003 // File: nn.h 00004 // 00005 // Created: 04/08/2000 00006 // 00007 // Author: Pavel Sakov 00008 // CSIRO Marine Research 00009 // 00010 // Purpose: Header file for nn library 00011 // 00012 // Description: None 00013 // 00014 // Revisions: None 00015 // 00016 //-------------------------------------------------------------------------- 00017 00018 #if !defined ( _NN_H ) 00019 #define _NN_H 00020 00021 #include "nndll.h" 00022 00023 typedef enum { SIBSON, NON_SIBSONIAN } NN_RULE; 00024 00025 #if !defined ( _POINT_STRUCT ) 00026 #define _POINT_STRUCT 00027 typedef struct 00028 { 00029 double x; 00030 double y; 00031 double z; 00032 } point; 00033 #endif 00034 00035 //* Smoothes the input point array by averaging the input x,y and z values 00036 //** for each cell within virtual rectangular nx by ny grid. The corners of the 00037 //** grid are created from min and max values of the input array. It also frees 00038 //** the original array and returns results and new dimension via original 00039 //** data and size pointers. 00040 //* 00041 //* @param pn Pointer to number of points (input/output) 00042 //* @param ppoints Pointer to array of points (input/output) [*pn] 00043 //* @param nx Number of x nodes in decimation 00044 //* @param ny Number of y nodes in decimation 00045 // 00046 void points_thin( int* n, point** points, int nx, int ny ); 00047 00048 //* Generates rectangular grid nx by ny using min and max x and y values from 00049 //** the input point array. Allocates space for the output point array, be sure 00050 //** to free it when necessary! 00051 //* 00052 //* @param n Number of points 00053 //* @param points Array of points [n] 00054 //* @param nx Number of x nodes 00055 //* @param ny Number of y nodes 00056 //* @param nout Pointer to number of output points 00057 //* @param pout Ppointer to array of output points [*nout] 00058 // 00059 void points_generate1( int n, point points[], int nx, int ny, double zoom, int* nout, point** pout ); 00060 00061 //* Generates rectangular grid nx by ny using specified min and max x and y 00062 //** values. Allocates space for the output point array, be sure to free it 00063 //** when necessary! 00064 //* 00065 //* @param xmin Min x value 00066 //* @param xmax Max x value 00067 //* @param ymin Min y value 00068 //* @param ymax Max y value 00069 //* @param nx Number of x nodes 00070 //* @param ny Number of y nodes 00071 //* @param zoom Zoom coefficient 00072 //* @param nout Pointer to number of output points 00073 //* @param pout Pointer to array of output points [*nout] 00074 // 00075 void points_generate2( double xmin, double xmax, double ymin, double ymax, int nx, int ny, int* nout, point** pout ); 00076 00077 //* Reads array of points from a columnar file. 00078 // 00079 // @param fname File name (can be "stdin" dor stndard input) 00080 // @param dim Number of dimensions (must be 2 or 3) 00081 // @param n Pointer to number of points (output) 00082 // @param points Pointer to array of points [*n] (output) 00083 // 00084 void points_read( char* fname, int dim, int* n, point** points ); 00085 00086 //* Scales Y coordinate so that the resulting set fits into square: 00087 //** xmax - xmin = ymax - ymin 00088 //* 00089 //* @param n Number of points 00090 //* @param points The points to scale 00091 //* @return Y axis compression coefficient 00092 // 00093 double points_scaletosquare( int n, point* points ); 00094 00095 //* Compresses Y domain by a given multiple. 00096 // 00097 // @param n Number of points 00098 // @param points The points to scale 00099 // @param Y axis compression coefficient as returned by points_scaletosquare() 00100 // 00101 void points_scale( int n, point* points, double k ); 00102 00103 //* Structure to perform the Delaunay triangulation of a given array of points. 00104 // 00105 // Contains a deep copy of the input array of points. 00106 // Contains triangles, circles and edges resulted from the triangulation. 00107 // Contains neighbour triangles for each triangle. 00108 // Contains point to triangle map. 00109 // 00110 struct delaunay; 00111 typedef struct delaunay delaunay; 00112 00113 //* Builds Delaunay triangulation of the given array of points. 00114 // 00115 // @param np Number of points 00116 // @param points Array of points [np] (input) 00117 // @param ns Number of forced segments 00118 // @param segments Array of (forced) segment endpoint indices [2*ns] 00119 // @param nh Number of holes 00120 // @param holes Array of hole (x,y) coordinates [2*nh] 00121 // @return Delaunay triangulation with triangulation results 00122 // 00123 delaunay* delaunay_build( int np, point points[], int ns, int segments[], int nh, double holes[] ); 00124 00125 //* Destroys Delaunay triangulation. 00126 // 00127 // @param d Structure to be destroyed 00128 // 00129 void delaunay_destroy( delaunay* d ); 00130 00131 //* `lpi' -- "linear point interpolator" is a structure for 00132 // conducting linear interpolation on a given data on a "point-to-point" basis. 00133 // It interpolates linearly within each triangle resulted from the Delaunay 00134 // triangluation of input data. `lpi' is much faster than all 00135 // Natural Neighbours interpolators below. 00136 // 00137 struct lpi; 00138 typedef struct lpi lpi; 00139 00140 //* Builds linear interpolator. 00141 // 00142 // @param d Delaunay triangulation 00143 // @return Linear interpolator 00144 // 00145 lpi* lpi_build( delaunay* d ); 00146 00147 //* Destroys linear interpolator. 00148 // 00149 // @param l Structure to be destroyed 00150 // 00151 void lpi_destroy( lpi* l ); 00152 00153 //* Finds linearly interpolated value in a point. 00154 // 00155 // @param l Linear point interpolator 00156 // @param p Point to be interpolated (p->x, p->y -- input; p->z -- output) 00157 // 00158 void lpi_interpolate_point( lpi* l, point* p ); 00159 00160 // Linearly interpolates data from one array of points for another array of 00161 // points. 00162 // 00163 // @param nin Number of input points 00164 // @param pin Array of input points [pin] 00165 // @param nout Number of ouput points 00166 // @param pout Array of output points [nout] 00167 // 00168 NNDLLIMPEXP 00169 void lpi_interpolate_points( int nin, point pin[], int nout, point pout[] ); 00170 00171 //* `nnpi' -- "Natural Neighbours point interpolator" is a 00172 // structure for conducting Natural Neighbours interpolation on a given data on 00173 // a "point-to-point" basis. Because it involves weight calculation for each 00174 // next output point, it is not particularly suitable for consequitive 00175 // interpolations on the same set of observation points -- use 00176 // `nnhpi' or `nnai' in these cases. 00177 // 00178 struct nnpi; 00179 typedef struct nnpi nnpi; 00180 00181 //* Creates Natural Neighbours point interpolator. 00182 // 00183 // @param d Delaunay triangulation 00184 // @return Natural Neighbours interpolation 00185 // 00186 nnpi* nnpi_create( delaunay* d ); 00187 00188 //* Destroys Natural Neighbours point interpolation. 00189 // 00190 // @param nn Structure to be destroyed 00191 // 00192 void nnpi_destroy( nnpi* nn ); 00193 00194 //* Finds Natural Neighbours-interpolated value in a point. 00195 // 00196 // @param nn NN point interpolator 00197 // @param p Point to be interpolated (p->x, p->y -- input; p->z -- output) 00198 // 00199 void nnpi_interpolate_point( nnpi* nn, point* p ); 00200 00201 //* Natural Neighbours-interpolates data in one array of points for another 00202 //** array of points. 00203 //* 00204 //* @param nin Number of input points 00205 //* @param pin Array of input points [pin] 00206 //* @param wmin Minimal allowed weight 00207 //* @param nout Number of output points 00208 //* @param pout Array of output points [nout] 00209 // 00210 NNDLLIMPEXP 00211 void nnpi_interpolate_points( int nin, point pin[], double wmin, int nout, point pout[] ); 00212 00213 //* Sets minimal allowed weight for Natural Neighbours interpolation. 00214 // @param nn Natural Neighbours point interpolator 00215 // @param wmin Minimal allowed weight 00216 // 00217 void nnpi_setwmin( nnpi* nn, double wmin ); 00218 00219 //* `nnhpi' is a structure for conducting consequitive 00220 // Natural Neighbours interpolations on a given spatial data set in a random 00221 // sequence of points from a set of finite size, taking advantage of repeated 00222 // interpolations in the same point. It allows to modify Z 00223 // coordinate of data between interpolations. 00224 // 00225 struct nnhpi; 00226 typedef struct nnhpi nnhpi; 00227 00228 //* Creates Natural Neighbours hashing point interpolator. 00229 // 00230 // @param d Delaunay triangulation 00231 // @param size Hash table size (should be of order of number of output points) 00232 // @return Natural Neighbours interpolation 00233 // 00234 nnhpi* nnhpi_create( delaunay* d, int size ); 00235 00236 //* Destroys Natural Neighbours hashing point interpolation. 00237 // 00238 // @param nn Structure to be destroyed 00239 // 00240 void nnhpi_destroy( nnhpi* nn ); 00241 00242 //* Finds Natural Neighbours-interpolated value in a point. 00243 // 00244 // @param nnhpi NN hashing point interpolator 00245 // @param p Point to be interpolated (p->x, p->y -- input; p->z -- output) 00246 // 00247 void nnhpi_interpolate( nnhpi* nn, point* p ); 00248 00249 //* Modifies interpolated data. 00250 // Finds point* pd in the underlying Delaunay triangulation such that 00251 // pd->x = p->x and pd->y = p->y, and copies p->z to pd->z. Exits with error 00252 // if the point is not found. 00253 // 00254 // @param nn Natural Neighbours hashing point interpolator 00255 // @param p New data 00256 // 00257 void nnhpi_modify_data( nnhpi* nn, point* p ); 00258 00259 //* Sets minimal allowed weight for Natural Neighbours interpolation. 00260 // @param nn Natural Neighbours point hashing interpolator 00261 // @param wmin Minimal allowed weight 00262 // 00263 void nnhpi_setwmin( nnhpi* nn, double wmin ); 00264 00265 // `nnai' is a tructure for conducting consequitive Natural 00266 // Neighbours interpolations on a given spatial data set in a given array of 00267 // points. It allows to modify Z coordinate of data between interpolations. 00268 // `nnai' is the fastest of the three Natural Neighbours 00269 // interpolators here. 00270 // 00271 struct nnai; 00272 typedef struct nnai nnai; 00273 00274 //* Builds Natural Neighbours array interpolator. This includes calculation of 00275 // weights used in nnai_interpolate(). 00276 // 00277 // @param d Delaunay triangulation 00278 // @return Natural Neighbours interpolation 00279 // 00280 nnai* nnai_build( delaunay* d, int n, double* x, double* y ); 00281 00282 //* Destroys Natural Neighbours array interpolator. 00283 // 00284 // @param nn Structure to be destroyed 00285 // 00286 void nnai_destroy( nnai* nn ); 00287 00288 //* Conducts NN interpolation in a fixed array of output points using 00289 // data specified for a fixed array of input points. Uses pre-calculated 00290 // weights. 00291 // 00292 // @param nn NN array interpolator 00293 // @param zin input data [nn->d->npoints] 00294 // @param zout output data [nn->n]. Must be pre-allocated! 00295 // 00296 void nnai_interpolate( nnai* nn, double* zin, double* zout ); 00297 00298 //* Sets minimal allowed weight for Natural Neighbours interpolation. 00299 // @param nn Natural Neighbours array interpolator 00300 // @param wmin Minimal allowed weight 00301 // 00302 void nnai_setwmin( nnai* nn, double wmin ); 00303 00304 // Sets the verbosity level within nn package. 00305 // 0 (default) - silent 00306 // 1 - verbose 00307 // 2 - very verbose 00308 // 00309 extern int nn_verbose; 00310 00311 // Switches between weight calculation methods. 00312 // SIBSON -- classic Sibson method 00313 // NON_SIBSONIAN -- simpler and (I think) more robust method 00314 // 00315 extern NNDLLIMPEXP_DATA( NN_RULE ) nn_rule; 00316 00317 // Contains version string for the nn package. 00318 // 00319 extern const char* nn_version; 00320 00321 // Limits verbose information to a particular vertex (used mainly for 00322 // debugging purposes). 00323 // 00324 extern int nn_test_vertice; 00325 00326 #endif // _NN_H