mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 11:50:57 +02:00
* Some fixes from Ondrej Pokorny (bug ID 29538)
git-svn-id: trunk@33062 -
This commit is contained in:
parent
c5a44f7487
commit
39c404d342
@ -89,11 +89,12 @@ end;
|
|||||||
function TPoint.Add(const apt: TPoint): TPoint;
|
function TPoint.Add(const apt: TPoint): TPoint;
|
||||||
begin
|
begin
|
||||||
result.x:=x+apt.x;
|
result.x:=x+apt.x;
|
||||||
|
result.y:=y+apt.y;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPoint.Distance(const apt : TPoint) : Double;
|
function TPoint.Distance(const apt: TPoint): ValReal;
|
||||||
begin
|
begin
|
||||||
result:=sqrt(sqr(apt.x-x)+sqr(apt.y-y));
|
result:=sqrt(sqr(ValReal(apt.x)-ValReal(x))+sqr(ValReal(apt.y)-ValReal(y))); // convert to ValReal to prevent integer overflows
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPoint.IsZero : Boolean;
|
function TPoint.IsZero : Boolean;
|
||||||
@ -104,6 +105,13 @@ end;
|
|||||||
function TPoint.Subtract(const apt : TPoint): TPoint;
|
function TPoint.Subtract(const apt : TPoint): TPoint;
|
||||||
begin
|
begin
|
||||||
result.x:=x-apt.x;
|
result.x:=x-apt.x;
|
||||||
|
result.y:=y-apt.y;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TPoint.Zero: TPoint;
|
||||||
|
begin
|
||||||
|
Result.x := 0;
|
||||||
|
Result.y := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPoint.SetLocation(const apt :TPoint);
|
procedure TPoint.SetLocation(const apt :TPoint);
|
||||||
@ -117,14 +125,20 @@ end;
|
|||||||
|
|
||||||
procedure TPoint.Offset(const apt :TPoint);
|
procedure TPoint.Offset(const apt :TPoint);
|
||||||
begin
|
begin
|
||||||
x:=x-apt.x;
|
x:=x+apt.x;
|
||||||
y:=y-apt.y;
|
y:=y+apt.y;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TPoint.PointInCircle(const apt, acenter: TPoint;
|
||||||
|
const aradius: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
Result := apt.Distance(acenter) <= aradius;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPoint.Offset(dx,dy : Longint);
|
procedure TPoint.Offset(dx,dy : Longint);
|
||||||
begin
|
begin
|
||||||
x:=x-dx;
|
x:=x+dx;
|
||||||
y:=y-dy;
|
y:=y+dy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class operator TPoint.= (const apt1, apt2 : TPoint) : Boolean;
|
class operator TPoint.= (const apt1, apt2 : TPoint) : Boolean;
|
||||||
|
@ -70,14 +70,16 @@
|
|||||||
constructor Create(ax,ay:Longint); overload;
|
constructor Create(ax,ay:Longint); overload;
|
||||||
constructor Create(apt :TPoint); overload;
|
constructor Create(apt :TPoint); overload;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
class function Zero: TPoint; static; inline;
|
||||||
function Add(const apt: TPoint): TPoint;
|
function Add(const apt: TPoint): TPoint;
|
||||||
function Distance(const apt : TPoint) : Double;
|
function Distance(const apt: TPoint) : ValReal;
|
||||||
function IsZero : Boolean;
|
function IsZero : Boolean;
|
||||||
function Subtract(const apt : TPoint): TPoint;
|
function Subtract(const apt : TPoint): TPoint;
|
||||||
procedure SetLocation(const apt :TPoint);
|
procedure SetLocation(const apt :TPoint);
|
||||||
procedure SetLocation(ax,ay : Longint);
|
procedure SetLocation(ax,ay : Longint);
|
||||||
procedure Offset(const apt :TPoint);
|
procedure Offset(const apt :TPoint);
|
||||||
procedure Offset(dx,dy : Longint);
|
procedure Offset(dx,dy : Longint);
|
||||||
|
class function PointInCircle(const apt, acenter: TPoint; const aradius: Integer): Boolean; static; inline;
|
||||||
class operator = (const apt1, apt2 : TPoint) : Boolean;
|
class operator = (const apt1, apt2 : TPoint) : Boolean;
|
||||||
class operator <> (const apt1, apt2 : TPoint): Boolean;
|
class operator <> (const apt1, apt2 : TPoint): Boolean;
|
||||||
class operator + (const apt1, apt2 : TPoint): TPoint;
|
class operator + (const apt1, apt2 : TPoint): TPoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user