Difference between revisions of "GroupTPA"
From SCAR Divi Manual
(Created page with "==Definition== <source lang="scar" lines="false"> function GroupTPA(const TPA: TPointArray; const Dist: Integer): T2DPointArray; </source> ==Availability== SCAR Divi 3.28 > Curr...") |
|||
(10 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
SCAR Divi 3.28 > Current | SCAR Divi 3.28 > Current | ||
− | *Contained a bug 3.26-3.27 that caused the initial element in every subarray of the result to be duplicated inside of that subarray. | + | *Contained a bug in 3.26-3.27 that caused the initial element in every subarray of the result to be duplicated inside of that subarray. |
+ | *In 3.26-3.27 the algorithm was implemented incorrectly and split every point of '''TPA''' up into a subarray and then included every other point within a distance of the first point in that subarray. | ||
===Aliases=== | ===Aliases=== | ||
− | *TPAGroup (SCAR Divi 3.26 > | + | *TPAGroup (SCAR Divi 3.26 > 3.34) |
+ | *TPAToATPA (SCAR Divi 3.26 > 3.34) | ||
==Description== | ==Description== | ||
− | This function splits a given [[TPointArray]] '''TPA''' into separate TPointArrays, | + | This function splits a given [[TPointArray]] '''TPA''' into separate TPointArrays, by grouping points that are within the given distance '''Dist''' of the first point of each subarray. If a point isn't within the given distance of any first point of the subarrays, a new subarray is created containing that point as first one. The function returns a [[T2DPointArray]] containing all the resulting TPointArrays. An extended function with additional functionality is available as [[GroupTPAEx]]. |
==Example== | ==Example== | ||
Line 25: | Line 27: | ||
ClearDebug; | ClearDebug; | ||
TPA := [Point(2, 5), Point(6, 9), Point(0, 0), Point(5, 5), Point(1, 1), Point(5, 7), Point(-2, 0)]; | TPA := [Point(2, 5), Point(6, 9), Point(0, 0), Point(5, 5), Point(1, 1), Point(5, 7), Point(-2, 0)]; | ||
− | ATPA := | + | ATPA := GroupTPA(TPA, 2); |
for i := 0 to High(ATPA) do | for i := 0 to High(ATPA) do | ||
WriteLn(TPAToStr(ATPA[i])); | WriteLn(TPAToStr(ATPA[i])); | ||
Line 36: | Line 38: | ||
(0,0);(1,1);(-2,0) | (0,0);(1,1);(-2,0) | ||
(5,5);(5,7) | (5,5);(5,7) | ||
− | |||
− | |||
− | |||
==See Also== | ==See Also== |
Latest revision as of 12:06, 8 September 2012
Definition
function GroupTPA(const TPA: TPointArray; const Dist: Integer): T2DPointArray;
Availability
SCAR Divi 3.28 > Current
- Contained a bug in 3.26-3.27 that caused the initial element in every subarray of the result to be duplicated inside of that subarray.
- In 3.26-3.27 the algorithm was implemented incorrectly and split every point of TPA up into a subarray and then included every other point within a distance of the first point in that subarray.
Aliases
- TPAGroup (SCAR Divi 3.26 > 3.34)
- TPAToATPA (SCAR Divi 3.26 > 3.34)
Description
This function splits a given TPointArray TPA into separate TPointArrays, by grouping points that are within the given distance Dist of the first point of each subarray. If a point isn't within the given distance of any first point of the subarrays, a new subarray is created containing that point as first one. The function returns a T2DPointArray containing all the resulting TPointArrays. An extended function with additional functionality is available as GroupTPAEx.
Example
var TPA: TPointArray; ATPA: T2DPointArray; i: Integer; begin ClearDebug; TPA := [Point(2, 5), Point(6, 9), Point(0, 0), Point(5, 5), Point(1, 1), Point(5, 7), Point(-2, 0)]; ATPA := GroupTPA(TPA, 2); for i := 0 to High(ATPA) do WriteLn(TPAToStr(ATPA[i])); end.
Output:
(2,5) (6,9) (0,0);(1,1);(-2,0) (5,5);(5,7)