{-------------------------------------------------------------------------------
Le tri se fait sur les valeurs d'angles croissant entre les couples de points
d'un tableau de TPoint.
-------------------------------------------------------------------------------}
Procedure TriTabSurAnglePoints(Var TbAng : array of Single;
Var TbP : Array Of TPoint;
Nvaleur : LongInt);
Var i,j,tx,ty : Integer;
Var ta : Single;
procedure permute;
begin
ta := TbAng[i];
tx := Tbp[i].X;
ty := Tbp[i].Y;
TbAng[i]:= TbAng[j];
Tbp[i].X:= Tbp[j].X;
Tbp[i].Y:= Tbp[j].Y;
TbAng[j]:= ta;
Tbp[j].X:= tx;
Tbp[j].Y:= ty;
end;
Begin
For i:=0 To NValeur -1 Do
For j:=i+1 To NValeur - 1 Do
begin
if TbAng[i] > TbAng[j]
Then permute
else if TbAng[i] = TbAng[j] then permute;
end;
End;
Exemple : 1. choisir un Point Pivot : Pivot.
2. on calcule les angles pour chacun des couples du tableau de Point
3. on trie par angles croissants
For i := 1 to NPoints do
begin
P[i]:= Point(random(200),random(100));
VTAngle[i] := FCAng2Pt2D(0,0,P[i].X-Pivot.X,P[i].Y-Pivot.Y);
end;
TriTabSurAnglePoints(VTAngle,P,NPoints);