Difference between revisions of "GroupTPAEx"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function GroupTPAEx(const TPA: TPointArray; const XMax, YMax: Integer): T2DPointArray; </source> ==Availability== SCAR Divi 3.2...")
 
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 SCAR Divi 3.26 - SCAR Divi 3.27 that caused the initial element in every subarray of the result to be duplicated inside of that subarray.
 +
*In SCAR Divi 3.26 - SCAR Divi 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 every point in that subarray.
  
 
===Aliases===
 
===Aliases===
Line 13: Line 14:
  
 
==Description==
 
==Description==
This function splits a given [[TPointArray]] '''TPA''' into separate TPointArrays, one for every element in '''TPA''' which is also the first element of every subarray. Next it adds every point that is within the given distance from that first point to the subarray. The distance is given separately for the x and y components of the points in '''XDist''' and '''YDist'''. The function returns a [[T2DPointArray]] containing all the resulting TPointArrays.
+
This function splits a given [[TPointArray]] '''TPA''' into separate TPointArrays, by grouping points that are within the given distance 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 distance is given separately for the x and y components of the points in '''XDist''' and '''YDist'''. The function returns a [[T2DPointArray]] containing all the resulting TPointArrays.
  
 
==Example==
 
==Example==
Line 36: Line 37:
 
  (0,0);(1,1);(-2,0)
 
  (0,0);(1,1);(-2,0)
 
  (5,5)
 
  (5,5)
(1,1);(0,0)
 
 
  (5,7)
 
  (5,7)
(-2,0);(0,0)
 
  
 
==See Also==
 
==See Also==

Revision as of 19:10, 2 November 2011

Definition

function GroupTPAEx(const TPA: TPointArray; const XMax, YMax: Integer): T2DPointArray;

Availability

SCAR Divi 3.28 > Current

  • Contained a bug in SCAR Divi 3.26 - SCAR Divi 3.27 that caused the initial element in every subarray of the result to be duplicated inside of that subarray.
  • In SCAR Divi 3.26 - SCAR Divi 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 every point in that subarray.

Aliases

  • TPAGroupEx (SCAR Divi 3.26 > Current)

Description

This function splits a given TPointArray TPA into separate TPointArrays, by grouping points that are within the given distance 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 distance is given separately for the x and y components of the points in XDist and YDist. The function returns a T2DPointArray containing all the resulting TPointArrays.

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 := GroupTPAEx(TPA, 2, 1);
  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)

See Also