From 0c391fdbce5a079cf03e483eb6174dd47806163d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Aug 2019 21:08:47 +0800 Subject: *misc --- Source/modules/asura-base/Math/Rect.hpp | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Source/modules/asura-base/Math/Rect.hpp (limited to 'Source/modules/asura-base/Math/Rect.hpp') diff --git a/Source/modules/asura-base/Math/Rect.hpp b/Source/modules/asura-base/Math/Rect.hpp new file mode 100644 index 0000000..af4fa78 --- /dev/null +++ b/Source/modules/asura-base/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