SortTPASpiral

From SCAR Divi Manual
Revision as of 12:28, 25 November 2012 by Freddy (talk | contribs) (Created page with "==Definition== <source lang="scar" lines="false"> procedure SortTPASpiral(var TPA: TPointArray); </source> ==Availability== SCAR Divi 3.38 > Current ==Description== Sorts a ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Definition

procedure SortTPASpiral(var TPA: TPointArray);

Availability

SCAR Divi 3.38 > Current

Description

Sorts a given TPointArray TPA in a spiral pattern, spiraling out from the origin (0, 0) using the fast ShellSort algorithm. An extended function with additional functionality is available as SortTPASpiralEx.

Example

var
  TPA: TPointArray;
  
begin   
  TPA := TPAFromBox(Box(-1, -1, 1, 1));
  SortTPASpiral(TPA);
  WriteLn(TPAToStr(TPA));              
end.

Output:

(0,0);(0,-1);(1,-1);(1,0);(1,1);(0,1);(-1,1);(-1,0);(-1,-1)

See Also