module; #include #include export module Math; export { struct Vector2 : D2D1_POINT_2F { }; struct Rect : D2D1_RECT_F { Vector2 size() const& { return { right - left, bottom - top }; } }; inline bool isIntersection(const Rect& lhs, const Rect& rhs) { auto ox1 = (lhs.left + lhs.right) * 0.5f; auto oy1 = (lhs.top + lhs.bottom) * 0.5f; auto ox2 = (rhs.left + rhs.right) * 0.5f; auto oy2 = (rhs.top + rhs.bottom) * 0.5f; auto rx1 = abs(lhs.right - lhs.left) * 0.5f; auto ry1 = abs(lhs.top - lhs.bottom) * 0.5f; auto rx2 = abs(rhs.right - rhs.left) * 0.5f; auto ry2 = abs(rhs.top - rhs.bottom) * 0.5f; return ((abs(ox1 - ox2) - (rx1 + rx2)) < -20.f) && ((abs(oy1 - oy2) - (ry1 + ry2)) < -20.f); } }