From 66bfb69e96b63421c75e0daf229929afa9ef6cec Mon Sep 17 00:00:00 2001 From: marcoonthegit Date: Fri, 30 Dec 2022 19:34:03 +0100 Subject: [PATCH] * Tpoint.Angle initial version using arctan2 (cherry picked from commit 5fb88cef003edfcfee602f9255680f0489ace467) --- rtl/inc/typshrd.inc | 5 +++++ rtl/inc/typshrdh.inc | 3 +++ rtl/win32/windows.pp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/rtl/inc/typshrd.inc b/rtl/inc/typshrd.inc index 68f3034359..eb9e05a0f7 100644 --- a/rtl/inc/typshrd.inc +++ b/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); diff --git a/rtl/inc/typshrdh.inc b/rtl/inc/typshrdh.inc index ee6d4b1ea8..d62adad1bf 100644 --- a/rtl/inc/typshrdh.inc +++ b/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; diff --git a/rtl/win32/windows.pp b/rtl/win32/windows.pp index 9bf2deb0e9..801aa93b29 100644 --- a/rtl/win32/windows.pp +++ b/rtl/win32/windows.pp @@ -53,6 +53,8 @@ interface implementation +uses math; + {$undef read_interface} {$define read_implementation}