求高手给个VC拟合曲线的程序

来源:百度知道 编辑:UC知道 时间:2024/06/11 05:29:50
就是我把通过实验得出的N组数据输入后,拟合出一条曲线

三次样条插值程序

float hypot(float X, float Y);
void tspLine(int n, int ch, int *Num, float x[], float y[], float u1[], float v1[], float tx1 = 0.0, float tx2 = 0.0, float ty1 = 0.0, float ty2 = 0.0);

float hypot(float X, float Y)
{
return sqrt(X * X + Y * Y);
}

void tspLine(int n, int ch, int *Num, float x[], float y[], float u1[], float v1[], float tx1, float tx2, float ty1, float ty2)
{
int i, j, iNum;
float *a, *b, *c, *dx, *dy;
float *qx, *qy;
float *t, *px, *py;
float tt, bx3, bx4, by3, by4;
float cx, cy;
float u[3];

a = new float[n + 1];
b = new float[n + 1];
c = new float[n + 1];
dx = new float[n + 1];
dy = new float[n + 1];
qx = new float[n + 1];
qy = new float[n + 1];
t = new float[n + 1];
px = new float[n + 1];
py = new float[n + 1];

iNum = 0;
for (i = 1; i <= n; i++)
t[i] = hypot(x[i]