⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_circle.c

📁 使用lm算法对二维圆数据进行拟和
💻 C
字号:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <io.h>
#include <sys/stat.h>
#include <process.h>
#include <string.h>
#include <limits.h>
#include "fitting.h"

#define X_REF 12.241
#define Y_REF 35.21
#define RADIUS 55.0
#define FILE_NAME "my_circle.asc"

int
put_to_file(FILE *fp, double x, double y) {
	fprintf(fp, "%lf %lf\n", x, y);
	return 0;
}
int
put_end (FILE *fp, char *str) {
	fprintf(fp, "%s\n", str);
	return 0;
}
	
int
main() {
	int i;
	double tmp_x, tmp_y, tmp;
	FILE *fp;
	if((fp=fopen(FILE_NAME, "w+")) == NULL) {
		printf("fail to open  the file\n");
		exit(0);
	}
	for(i=0; i<1000; i++) {
		//printf("%d\n", i);
		tmp_x += 0.05;
		tmp = RADIUS*RADIUS-(tmp_x-X_REF)*(tmp_x-X_REF);
		if(tmp < 0) {
			printf("error parameter\n");
			exit(0);
		}
		tmp_y = sqrt(tmp)+Y_REF;
		put_to_file(fp, tmp_x, tmp_y);
	}
	put_end(fp, "**end cloud**");
	fclose(fp);
	return 0;		
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -