目的是输入一段曲线的首尾点,然后利用垂距法得到特征点,以此重新产生两端曲线进行递归,请问下面代码哪里出错了呢
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
namespace test1
{
public class DG
{
List<Point> PList;
public List<Point> keep = new List<Point>();
public int index = 0;
ArrayList d = new ArrayList();
ArrayList dtemp = new ArrayList();
double D = 10.0;
public DG()
{ }
public DG(List<Point> List)
{
PList = List;
}
public void getID(int bid,int eid)
{
Vector temp = new Vector();
for (int i = 0; i < eid - bid + 1; i++)
{
Vector iTOb = new Vector(PList[i],PList[bid]);
Vector iTOe = new Vector(PList[i],PList[eid]);
Vector bTOe = new Vector(PList[bid], PList[eid]);
double length = temp.Length(bTOe);
double cross = Math.Abs(temp.VectorX(iTOb, iTOe)) / 2.0;
double t = cross / length;
d.Add(t);
dtemp.Add(t);
}
if (eid <= bid + 1)
{
return;
}
dtemp.Sort();
dtemp.Reverse();
int maxindex = d.IndexOf(dtemp[0]);
if (((double)dtemp[0]) > D)
{
keep.Add(PList[maxindex]);
d.Clear();
dtemp.Clear();
getID(bid, maxindex);
getID(maxindex, eid);
index++;
}
else return;
}
}
}