Changeset 345 for trunk/Geometry.pas


Ignore:
Timestamp:
Dec 23, 2024, 11:25:36 AM (8 hours ago)
Author:
chronos
Message:
  • Modified: Improved test cases.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Geometry.pas

    r317 r345  
    9696    constructor Create(const Points: TPointArray); overload;
    9797    constructor Create(const Rect: TGRect<T>); overload;
     98    function Compare(Polygon: TGPolygon<T>): Boolean;
    9899    procedure Move(P: T);
    99100    function GetRect: TGRect<T>;
     
    239240  Self.Points[2] := Rect.P2;
    240241  Self.Points[3] := T.Create(Rect.P1.X, Rect.P2.Y);
     242end;
     243
     244function TGPolygon<T>.Compare(Polygon: TGPolygon<T>): Boolean;
     245var
     246  I: Integer;
     247begin
     248  Result := Length(Points) = Length(Polygon.Points);
     249  if not Result then Exit;
     250  for I := 0 to Length(Points) - 1 do
     251    if Points[I] <> Polygon.Points[I] then begin
     252      Result := False;
     253      Break;
     254    end;
    241255end;
    242256
Note: See TracChangeset for help on using the changeset viewer.