From b2a592de7f10dd3cf8965c809dffb5845477580f Mon Sep 17 00:00:00 2001 From: blikblum Date: Sat, 18 Jun 2011 12:35:25 +0000 Subject: [PATCH] * added overload to T2DIntVector.DistanceTo accepting x y coordinates git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1701 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/spktoolbar/SpkMath/SpkMath.pas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/spktoolbar/SpkMath/SpkMath.pas b/components/spktoolbar/SpkMath/SpkMath.pas index c6d9fa0e3..f50e76391 100644 --- a/components/spktoolbar/SpkMath/SpkMath.pas +++ b/components/spktoolbar/SpkMath/SpkMath.pas @@ -45,11 +45,15 @@ type function Length : extended; end; {$else} + + { T2DIntVector } + T2DIntVector = object x, y : integer; public - constructor Create(Ax, Ay : integer); + constructor Create(Ax, Ay : Integer); function DistanceTo(AVector : T2DIntVector) : double; + function DistanceTo(Ax, Ay : Integer) : double; function Length : extended; end; {$endif} @@ -353,6 +357,11 @@ begin result:=sqrt(sqr(self.x - AVector.x) + sqr(self.y - AVector.y)); end; +function T2DIntVector.DistanceTo(Ax, Ay: Integer): double; +begin + Result := sqrt(sqr(x - Ax) + sqr(y - Ay)); +end; + function T2DIntVector.Length: extended; begin result:=sqrt(sqr(Self.x)+sqr(self.y));