曲线拟合算法
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
曲线拟合算法:
本人进行测试通过,完全正常使用。
#region splined
private void splined(PointF[] temp, ref ArrayList splinedPt)
{
double x, y, t;
double px, py;
int q = 3;
int phi;
int kaw;
int naw;
int n = temp.Length;
int add;
phi = 5;
naw = n;
add = 5 * (naw + q - 1) + 1;
for (t = -phi + 1.0; t < naw + phi; t = t + 0.2)
{
x = 0.0;
y = 0.0;
for (kaw = -2 * phi + 1; kaw < naw + 2 * phi; kaw++)
{
px = 0;
py = 0;
if (kaw < 1)
{
px = temp[0].X;
py = temp[0].Y;
}
if (kaw > naw)
{
px = temp[naw - 1].X;
py = temp[naw - 1].Y;
}
if (kaw > 0 && kaw <= naw)
{
px = temp[kaw - 1].X;
py = temp[kaw - 1].Y;
}
x = x + nqt(q, t - kaw) * px;
y = y + nqt(q, t - kaw) * py;
}
PointF Point1 = new PointF((float)x, (float)y);
splinedPt.Add(Point1);
}
} //splined
private double nqt(double qq, double tt)
{
double re, re1, re2, re3;
re = 0;
if (qq == 1)
{
re = 0.0;
if (tt > -1.0 && tt <= 0.0)
re = tt + 1.0;
if (tt > 0.0 && tt < 1.0)
re = -tt + 1.0;
}
else
{
re = 0.0;
if (tt > -(qq + 1.0) / 2.0 && tt < (qq + 1.0) / 2.0)
{
re1 = 1.0 / qq;
re2 = (tt + (qq + 1.0) / 2.0) * nqt(qq - 1, tt + 0.5);
re3 = ((qq + 1.0) / 2.0 - tt) * nqt(qq - 1, tt - 0.5);
re = re1 * (re2 + re3);
}
}
return re;
}
#endregion
调用实例:
ArrayList splinedPt = new ArrayList();
splined(tt, ref splinedPt);