#include <stdio.h>
/* Function prototype for c_natgrids */
extern float *c_natgrids(int, float [], float [], float [],
int, int, float [], float [], int *);
/* Specify number of input data points and the size of the output grid */
#define NUMIN 80732
#define NUMXOUT 600
#define NUMYOUT 200
/* Specify the range of the input, or type NULL to have the program calculate it */
#define XMAX 167
#define XMIN 161
#define YMAX 74
#define YMIN 72
main(int argc, char *argv[])
{
FILE *in;
int i, j, k, ier, count=0, nitems, temp;
float *out, xo[NUMXOUT], yo[NUMYOUT], xc, yc;
float x[NUMIN], y[NUMIN], z[NUMIN];
float x_max, x_min, y_max, y_min;
/* Check if the file argument is present */
if (!argv[1]) {
printf( "\nNo input file specified\n" );
exit(0);
}
/* Check if the file exists */
in=fopen(argv[1],"r");
if (in == NULL) {
printf( "\nUnable to open file\n" );
exit(0);
}
/* Read in longitude, latitude, and elevation from file */
while(1)
{
nitems = fscanf(in, "%f\t%f\t%f\n", &x[count], &y[count], &z[count]);
if (nitems == EOF)
break;
count++;
}
/* Find the x and y range of input */
if ((XMAX == NULL) || (XMIN == NULL) || (YMAX == NULL) || (YMIN == NULL)) {
x_max = x[0];
x_min = x[0];
y_max = y[0];
y_min = y[0];
for (temp=0; temp < count; temp++) {
if (x[temp] > x_max) { x_max = x[temp]; }
if (x[temp] < x_min) { x_min = x[temp]; }
if (y[temp] > y_max) { y_max = y[temp]; }
if (y[temp] < y_min) { y_min = y[temp]; }
}
}
if (XMAX != NULL) { x_max = XMAX; }
if (XMIN != NULL) { x_min = XMIN; }
if (YMAX != NULL) { y_max = YMAX; }
if (YMIN != NULL) { y_min = YMIN; }
/* Calculate the x coordinates of the output grid */
xc = (x_max-x_min)/(NUMXOUT-1);
for (i = 0 ; i < NUMXOUT ; i++) {
xo[i] = i * xc + x_min;
}
/* Calculate the y coordinates of the output grid */
yc = (y_max-y_min)/(NUMYOUT-1);
for (j = 0 ; j < NUMYOUT ; j++) {
yo[j] = j * yc + y_min;
}
/* Set flag for nonlinear interpolation */
c_nnseti("igr",1);
/* Run the natural neighbor function */
out = c_natgrids(NUMIN, x, y, z, NUMXOUT, NUMYOUT, xo, yo, &ier);
/* Check if any errors were encountered by c_natgrids */
if (ier != 0) {
printf (" Error return from c_natgrids = %d\n",ier);
}
/* Output the results */
for (k = 0; k < NUMXOUT*NUMYOUT; k++) {
printf ("%f\n", out[k]);
}
fclose(in);
}
natgrid_nonlinear.rar_网格插值
版权申诉
36 浏览量
2022-07-15
02:41:36
上传
评论
收藏 1KB RAR 举报
alvarocfc
- 粉丝: 109
- 资源: 1万+
最新资源
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- python课程设计-基于tensorflow实现的图文生成程序,数据集flickr30k-images+源代码+文档说明+截图
- python作业-基于Flickr30k数据集实现图像文本跨模态搜索python源码+数据集+测试界面+项目说明(高分课程设计)
- 基于Qt实现医院信息管理系统c++源码+文档说明+数据库(期末大作业)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈