From bad78945ceba425f6a80e3b8dca2414d592970eb Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 2 Aug 2019 20:51:00 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E5=90=8D=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/modules/asura-utils/Math/Rect.hpp | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 source/modules/asura-utils/Math/Rect.hpp (limited to 'source/modules/asura-utils/Math/Rect.hpp') diff --git a/source/modules/asura-utils/Math/Rect.hpp b/source/modules/asura-utils/Math/Rect.hpp new file mode 100644 index 0000000..45bf1ba --- /dev/null +++ b/source/modules/asura-utils/Math/Rect.hpp @@ -0,0 +1,50 @@ +#ifndef _ASURA_ENGINE_RECT_H_ +#define _ASURA_ENGINE_RECT_H_ + +namespace AsuraEngine +{ + namespace Math + { + + template + struct Rect + { + public: + Rect(); + Rect(T x, T y, T w, T h); + ~Rect() {}; + + /// + /// x,y是否落在rect内。 + /// + bool Contain(T x, T y); + + /// + /// 两个矩形是否相交,并返回相交的矩形 + /// + bool Intersect(const Rect& src, Rect& intersection); + + /// + /// 两个矩形是否相交,并返回相交的矩形 + /// + static bool Intersect(const Rect& src1, const Rect& src2, Rect& intersection); + + void Set(T x, T y, T w, T h); + + T x, y, w, h; + }; + +#include "Rect.inc" + + // Define the most common types + typedef Rect Recti; + typedef Rect Rectu; + typedef Rect Rectf; + typedef Rect Reftl; + + } +} + +namespace AEMath = AsuraEngine::Math; + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0