diff --git a/dgl/Geometry.hpp b/dgl/Geometry.hpp index 1f6433b0..9ac9483b 100644 --- a/dgl/Geometry.hpp +++ b/dgl/Geometry.hpp @@ -753,6 +753,11 @@ public: */ bool contains(const Point& pos) const noexcept; + /** + Check if this rectangle contains the point @a pos affected by a custom scale. + */ + bool containsAfterScaling(const Point& pos, double scaling) const noexcept; + /** Check if this rectangle contains the point @a pos of another type. */ diff --git a/dgl/src/Geometry.cpp b/dgl/src/Geometry.cpp index dafa7089..44e99185 100644 --- a/dgl/src/Geometry.cpp +++ b/dgl/src/Geometry.cpp @@ -925,6 +925,12 @@ bool Rectangle::contains(const Point& p) const noexcept return (p.x >= pos.x && p.y >= pos.y && p.x <= pos.x+size.fWidth && p.y <= pos.y+size.fHeight); } +template +bool Rectangle::containsAfterScaling(const Point& p, const double scaling) const noexcept +{ + return (p.x >= pos.x && p.y >= pos.y && p.x/scaling <= pos.x+size.fWidth && p.y/scaling <= pos.y+size.fHeight); +} + template bool Rectangle::containsX(const T& x) const noexcept {