SortATPAByMeanEx

From SCAR Divi Manual
Revision as of 19:08, 22 November 2012 by Freddy (talk | contribs) (Created page with "==Definition== <source lang="scar" lines="false"> procedure SortATPAByMeanEx(var ATPA: T2DPointArray; const Point: TPoint); </source> ==Availability== SCAR Divi 3.38 > Curren...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Definition

procedure SortATPAByMeanEx(var ATPA: T2DPointArray; const Point: TPoint);

Availability

SCAR Divi 3.38 > Current

Aliases

  • SortATPAByMiddle (SCAR Divi 3.28 > 3.37)

Description

Sorts the given T2DPointArray ATPA by the distance of the arithmetic mean of the points of every non-empty subarray calculated with TPAMean to the TPoint given in Point using the fast ShellSort algorithm. Empty subarrays are placed at the start of the array.

Example

var
  ATPA: T2DPointArray;
  i: Integer;

begin
  SetLength(ATPA, 3);
  ATPA[0] := [Point(1, 6), Point(5, 4), Point(1, 5)];
  ATPA[1] := [Point(1, 1), Point(2, 2)];
  ATPA[2] := [Point(5, 10)];
  SortATPAByMeanEx(ATPA, Point(5, 5));
  for i := 0 to High(ATPA) do
    WriteLn(TPAToStr(ATPA[i]));
end.

Output:

(1,6);(5,4);(1,5)
(5,10)
(1,1);(2,2)

See Also