g.DrawLine(pen, new Point((int)ad[h - 1].x, (int)ad[h - 1].y), new Point((int)pd.x, (int)pd.y));
图 5-5 gdr路由模拟
5.6 CR路由模拟模块功能
Cr路由模拟模块功能选择模拟路径并且显示出来。代码如下:
while (juli(ps, pd) > 30)
{
j = 0;
for (int i = 0; i < 32; i++)
{
if (ps.x == aa[i].x && ps.y == aa[i].y)
continue;
if (juli(ps, aa[i]) < 30.0)
ac[j++] = aa[i]; }
double max = jiaodu(ac[0], ps, pd);
ps1 = ac[0];
for (int i = 1; i < j; i++)
if (jiaodu(ac[i], ps, pd) > max)
{
ps1 = ac[i];
max = jiaodu(ac[i], ps, pd);
}
jl[1] += juli(ps, ps1);
nl[1] += (juli(ps, ps1) * juli(ps, ps1));
ps = ps1;
ad[h++] = ps;
}
jl[1] += juli(ad[h - 1], pd);
nl[1] += (juli(ad[h - 1], pd) * juli(ad[h - 1], pd));
ts[1] = h+1;
Graphics g = this.CreateGraphics();
Pen pen = new Pen(Color.Blue, 2);
g.DrawLine(pen, new Point((int)ps2.x, (int)ps2.y), new Point((int)ad[0].x, (int)ad[0].y)); 无线传感器网络中数据传输最优路径选择(14):http://www.751com.cn/tongxin/lunwen_2234.html