废话不多说,直接上算法:
折线等分算法:
share = 20; //要等分的份数;
length = line.GetLength(); //线的长度;
num = line.GetPointsNum(); //线上的形状点个数;
step = length/share; //步长长度;
cur_span = step;
x1 = line.GetPointAt(1).GetX();
x1 = line.GetPointAt(1).GetY();
for i = 2 to num
x2 = line.GetPointAt(i).GetX();
x2 = line.GetPointAt(i).GetY();
do while true
cur_distance = GetDistance(x1,y1,x2,y2);
if cur_distance>=cur_span then
x = (x2-x1)*cur_span/cur_distance + x1
y = (y2-y1)*cur_span/cur_distance + y1
ArrayResult.push(x, y); //把生成的等分点加到结果数组中;
x1 = x
y1 = y
cur_span = step
else then
x1 = x2
y1 = y2
cur_span = cur_span-cur_distance
exit do
end if
loop
end for