Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(list: TPointArray; w,h: Int32): T2DPointArray;
- var
- lo,hi: Int32;
- function extract_connections_of(p: TPoint): TPointArray;
- var i: Int32;
- begin
- for i:=hi downto lo+1 do
- // the distance parameter
- if (Abs(p.x-list[i].x) <= w) and (Abs(p.y-list[i].y) <= h) then
- begin
- Result += list[i];
- Swap(list[i], list[hi]); //move towards end
- Dec(hi); //and ever look at it again
- end;
- end;
- function recurse_connections(p: TPoint): TPointArray;
- var i: Int32;
- begin
- Result := extract_connections_of(p);
- for i:=0 to High(result) do
- Result += recurse_connections(result[i]); //extend
- end;
- begin
- lo := 0;
- hi := High(list);
- while lo <= hi do
- begin
- Result += recurse_connections(list[lo]) + [list[lo]]; //append
- inc(lo);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement