From c302f5ae5f9e30a28e487e8a764d9cc31546bbea Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 29 Mar 2019 22:51:04 +0800 Subject: *rename --- source/modules/asura-utils/math/rect.hpp | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 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..1751634 --- /dev/null +++ b/source/modules/asura-utils/math/rect.hpp @@ -0,0 +1,47 @@ +#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); + + /// + /// 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); + + T x, y, w, h; + }; + +#include "Rect.inl" + + // 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