DESCRIPTION 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. DESCRIPTION OF INTERPOLATION LIBRARY
  2. written by Irina Kosinovsky 1995
  3. this description was not edited/reviewed, please use with caution
  4. double
  5. IL_crst (r,fi)
  6. double r; /* radius */
  7. double fi; /* tension */
  8. Radial based generating function - completely regularized spline
  9. with tension (d=2)
  10. int
  11. IL_crstg (r, fi, gd1, gd2)
  12. double r; /* radius */
  13. double fi; /* tension */
  14. double *gd1;
  15. double *gd2;
  16. Function for calculating derivatives (d=2)
  17. int
  18. IL_input_data_2d(fdinp,root,zmult,xmin,xmax,ymin,ymax,zmin,zmax,
  19. MAXPOINTS,KMIN,KMAX,n_points)
  20. FILE *fdinp; /* input stream */
  21. struct multtree *root; /* quadtree */
  22. double zmult; /* multiplier for z-values */
  23. double *xmin,*xmax,*ymin,*ymax,*zmin,*zmax;
  24. int maxpoints; /* max number of points per segment for interpolation */
  25. int kmin; /* min number of points per segment for interpolation */
  26. int kmax; /* max number of points per segment */
  27. int *n_points; /* number of points used for interpolation */
  28. Inserts input data inside the region into a quad tree.
  29. Also translates data.
  30. Returns number of segments in the quad tree.
  31. int
  32. IL_create_bitmask(maskmap,bitmask,nsizr,nsizc)
  33. char *maskmap; /* name of mask */
  34. struct BM *bitmask;
  35. int nsizr,nsizc; /* number of rows and columns */
  36. Creates a bitmap mask from given raster file
  37. int
  38. IL_grid_calc_2d(data,az,adx,ady,adxx,adyy,adxy,
  39. Tmp_fd_z,Tmp_fd_dx,Tmp_fd_dy,Tmp_fd_xx,Tmp_fd_yy,Tmp_fd_xy,
  40. bitmask,dnorm,zmin,zmax,zminac,zmaxac,gmin,gmax,
  41. c1min,c1max,c2min,c2max,ertot,fi,KMAX2,b,scik1,scik2,scik3,offset1,
  42. secpar,interp,interpder,wr_temp)
  43. struct quaddata *data; /* given segment */
  44. double *az,*adx,*ady,*adxx,*adyy,*adxy; /* array for interpolated values */
  45. FILE *Tmp_fd_z,*Tmp_fd_dx,*Tmp_fd_dy, /* temp files for writing interp.*/
  46. *Tmp_fd_xx,*Tmp_fd_yy,*Tmp_fd_xy; /* values */
  47. struct BM *bitmask; /* bitmask */
  48. double dnorm; /* normalization factor */
  49. double zmin,zmax; /* min and max input z-values */
  50. double *zminac,*zmaxac, /* min and max interp. z-values */
  51. *gmin,*gmax, /* min and max inperp. slope val.*/
  52. *c1min,*c1max,*c2min,*c2max; /* min and max interp. curv. val.*/
  53. double *ertot; /* total interplating func. error*/
  54. double fi, /* tension */
  55. int KMAX2; /* max num. of points for interp.*/
  56. double *b; /* solutions of linear equations */
  57. int scik1,scik2,scik3; /* multipliers for interp. values*/
  58. int offset1; /* offset for temp file writing */
  59. int (*secpar) (); /* calculates aspect,slope,curv. */
  60. double (*interp) (); /* radial based interp. function*/
  61. int (*interpder) (); /* interp. func. for derivatives */
  62. int (*wr_temp) (); /* writes temp files */
  63. Calculates grid for the given segment represented by data (contains n_rows,
  64. n_cols, ew_res,ns_res, and all points inside + overlap) using solutions of
  65. system of lin. equations and interpolating functions interp() and interpder().
  66. Also calls secpar() to compute slope, aspect and curvatures if required.
  67. int
  68. IL_matrix_create(points,n_points,matrix,indx,fi,rsm,interp)
  69. struct triple *points; /* points for interpolation */
  70. int n_points; /* number of points */
  71. double **matrix; /* matrix */
  72. int *indx;
  73. double fi; /* tension */
  74. double rsm; /* smoothing */
  75. double (*interp) (); /* interpolating function */
  76. Creates system of linear equations represented by matrix using given points
  77. and interpolating function interp()
  78. int
  79. IL_check_at_points_2d (n_points, points,b,ertot,tension,interp,zmin,dnorm)
  80. int n_points; /* number of points */
  81. struct triple *points; /* points for interpolation */
  82. double *b; /* solution of linear equations */
  83. double *ertot; /* total error */
  84. double tension; /* tension */
  85. double (*interp) ();/* interpolating function */
  86. double zmin; /* min z-value */
  87. double dnorm; /* normalizing factor */
  88. Checks if interpolating function interp() evaluates correct z-values at given
  89. points. If smoothing is used calculate the maximum error caused by smoothing.
  90. int
  91. IL_secpar_loop_2d(ngstc,nszc,k,bitmask,adx,ady,adxx,adyy,adxy,
  92. gmin,gmax,c1min,c1max,c2min,c2max,cond1,cond2)
  93. int ngstc; /* starting column */
  94. int nszc; /* ending column */
  95. int k; /* current row */
  96. struct BM *bitmask;
  97. double *adx,*ady,*adxx,*adyy,*adxy; /* derivatives */
  98. double *gmin,*gmax,*c1min,*c1max,*c2min,*c2max; /* min,max interp. values */
  99. int cond1,cond2; /*determine if particular values need to be computed*/
  100. Computes slope, aspect and curvatures (depending on cond1, cond2) for derivative
  101. arrays adx,...,adxy between columns ngstc and nszc.
  102. int
  103. IL_write_temp_2d(ngstc,nszc,offset2,Tmp_fd_z,Tmp_fd_dx,Tmp_fd_dy,Tmp_fd_xx,
  104. Tmp_fd_yy,Tmp_fd_xy,
  105. az,adx,ady,adxx,adyy,adxy,scik1,scik2,scik3)
  106. int ngstc,nszc,offset2; /* begin. and end. column, offset */
  107. FILE *Tmp_fd_z,*Tmp_fd_dx,*Tmp_fd_dy, /* Temp files */
  108. *Tmp_fd_xx,*Tmp_fd_yy,*Tmp_fd_xy;
  109. double *az,*adx,*ady,*adxx,*adyy,*adxy; /* interpolated values */
  110. int scik1,scik2,scik3; /* mutipliers for interp. values */
  111. Writes az,adx,...,adxy into appropriate place (depending on ngstc, nszc and
  112. offset) in corresponding temp file */
  113. int
  114. IL_interp_segments_2d (root, tree,az,adx,ady,adxx,adyy,adxy,
  115. Tmp_fd_z,Tmp_fd_dx,Tmp_fd_dy,Tmp_fd_xx,Tmp_fd_yy,Tmp_fd_xy,bitmask,
  116. dnorm,zmin,zmax,zminac,zmaxac,gmin,gmax,c1min,c1max,
  117. c2min,c2max,ertot,fi,KMIN,KMAX2,totsegm,rsm,scik1,scik2,scik3,offset1,
  118. grid_calc,matrix_create,check_points,secpar,interp,interpder,wr_temp)
  119. struct multtree *root; /* root of the quad tree */
  120. struct multtree *tree; /* current leaf of the quad tree */
  121. double *az,*adx,*ady,*adxx, /* interp. value arrays (for gridcalc()*/
  122. *adyy,*adxy;
  123. FILE *Tmp_fd_z,*Tmp_fd_dx,*Tmp_fd_dy, /* temp files for writing */
  124. *Tmp_fd_xx,*Tmp_fd_yy,*Tmp_fd_xy; /* for gridcalc() */
  125. struct BM *bitmask; /* bitmask */
  126. double dnorm; /* normalizing factor */
  127. double zmin,zmax; /* min and max input z-values */
  128. double *zminac,*zmaxac, /* min and max interp. z-values */
  129. *gmin,*gmax, /* min and max inperp. slope val.*/
  130. *c1min,*c1max,*c2min,*c2max; /* min and max interp. curv. val.*/
  131. double *ertot; /* total interplating func. error*/
  132. double fi, /* tension */
  133. int KMIN; /* min num. of points for interp.*/
  134. int KMAX2; /* max num. of points for interp.*/
  135. int totsegm; /* total number of segments */
  136. double rsm; /* smoothing (for matrix comput.)*/
  137. int scik1,scik2,scik3; /* multipliers for interp. values*/
  138. int offset1; /* offset for temp file writing */
  139. int (*grid_calc) (); /*calculates grid for given segm*/
  140. int (*matrix_create) (); /*creates matrix for a given segm*/
  141. int (*check_points) (); /*checks interp. func. at points */
  142. int (*secpar) (); /* calculates aspect,slope,curv. */
  143. double (*interp) (); /* radial based interp. function*/
  144. int (*interpder) (); /* interp. func. for derivatives */
  145. int (*wr_temp) (); /* writes temp files */
  146. Recursively processes each segment in a tree by
  147. a) finding points from neighbouring segments so that the total number of
  148. points is between KMIN and KMAX2 by calling tree function MT_get_region().
  149. b) creating and solving the system of linear equations using these points
  150. and interp() by calling matrix_create() and G_ludcmp().
  151. c) checking the interpolating function values at points by calling
  152. check_points().
  153. d) computing grid for this segment using points and interp() by calling
  154. grid_calc().
  155. int
  156. IL_output_2d (cellhd,nsizr,nsizc,elev,slope,aspect,pcurv,tcurv,mcurv,
  157. Tmp_fd_z,Tmp_fd_dx,Tmp_fd_dy,Tmp_fd_xx,Tmp_fd_yy,Tmp_fd_xy,
  158. zmin,zmax,zminac,zmaxac,c1min,c1max,c2min,c2max,gmin,gmax,scik1,scik2,scik3,
  159. dmin,fi,rsm,dnorm,zmult,KMAX,KMIN,ertot,input)
  160. struct Cell_head *cellhd; /* current region */
  161. int nsizr,nsizc; /* number of rows,columns */
  162. char *elev,*slope,*aspect,*pcurv,*tcurv,*mcurv; /* output files */
  163. FILE *Tmp_fd_z,*Tmp_fd_dx,*Tmp_fd_dy, /* temp files */
  164. *Tmp_fd_xx,*Tmp_fd_yy,*Tmp_fd_xy;
  165. double zmin,zmax, /* min,max input z-values */
  166. zminac,zmaxac,c1min,c1max, /* min,max interpolated values */
  167. c2min,c2max,gmin,gmax;
  168. int scik1,scik2,scik3; /*multipliers for interp. values */
  169. double dmin; /* min distance between points */
  170. double fi, /* tension */
  171. double rsm; /* smoothing (for matrix comput.)*/
  172. double dnorm; /* normalizing factor */
  173. double zmult; /* multiplier for z-values */
  174. int KMAX; /* max number of points per segm*/
  175. int KMIN; /* min num. of points for interp.*/
  176. double *ertot; /* total interplating func. error*/
  177. char *input; /* input file name */
  178. Creates output files as well as history files and color tables for them.