📄 linefit.cpp
字号:
//---------------------------------------------------------------------------
#pragma hdrstop
#include "LineFit.h"
#include <assert.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
/*LineFit::LineFit(Tpoint l_point[],int n_point)
{
//TODO: Add your source code here
assert(n_point);
double av_x,av_y;
double l_xx,l_yy,l_xy;
av_x = 0;
av_y = 0;
l_xx = 0;
l_yy = 0;
l_xy = 0;
for(int i = 0;i<n_point;i++)
{
av_x += l_point[i].x/n_point;
av_y += l_point[i].y/n_point;
}
for(int i = 0;i<n_point;i++)
{
l_xx += (l_point[i].x - av_x)*(l_point[i].x - av_x);
l_yy += (l_point[i].y - av_y)*(l_point[i].y - av_y);
l_xy += (l_point[i].x - av_x)*(l_point[i].y - av_y);
}
a = l_xy/l_xx;
b = av_y - l_xy*av_x/l_xx;
r = l_xy/sqrt(l_xx*l_yy);
}
double __fastcall LineFit::get_x(double y)
{
//TODO: Add your source code here
assert(a);
double x;
x=(y-b)/a;
return x;
}
double __fastcall LineFit::get_y(double x)
{
//TODO: Add your source code here
double y;
y=a*x+b;
return y;
} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -