Pārlūkot izejas kodu

* Tpoint.Angle initial version using arctan2

(cherry picked from commit 5fb88cef003edfcfee602f9255680f0489ace467)
marcoonthegit 2 gadi atpakaļ
vecāks
revīzija
66bfb69e96
3 mainītis faili ar 10 papildinājumiem un 0 dzēšanām
  1. 5 0
      rtl/inc/typshrd.inc
  2. 3 0
      rtl/inc/typshrdh.inc
  3. 2 0
      rtl/win32/windows.pp

+ 5 - 0
rtl/inc/typshrd.inc

@@ -141,6 +141,11 @@ begin
   y:=y+dy;
 end;
 
+function TPoint.Angle(const pt: TPoint): Single;
+begin
+  result:=ArcTan2(y-pt.y,x-pt.x);
+end;
+
 class operator TPoint.= (const apt1, apt2 : TPoint) : Boolean;
 begin
   result:=(apt1.x=apt2.x) and (apt1.y=apt2.y);

+ 3 - 0
rtl/inc/typshrdh.inc

@@ -59,6 +59,8 @@
      end;
   PSize =^TSize;
 
+  { TPoint }
+
   TPoint  =
   {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
    packed
@@ -79,6 +81,7 @@
        procedure SetLocation(ax,ay : Longint);
        procedure Offset(const apt :TPoint);
        procedure Offset(dx,dy : Longint);
+       function Angle(const pt : TPoint):Single;
        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;

+ 2 - 0
rtl/win32/windows.pp

@@ -53,6 +53,8 @@ interface
 
 implementation
 
+uses math;
+
 {$undef read_interface}
 {$define read_implementation}