Greetings,
Let's say we have a region with many rects in it such that all those rects do not overlap
Now if I want to add another rect into this region, say, [ljass] set r = Rect(minX, minY, maxX, maxY) [/ljass], how would I check if [ljass]r[/ljass] is in the region?
Intuitively, we could do:
But this test fails in 2 general cases as pictured below:
So this implies that simple point check is insufficient (i.e. check using 4 corners, check using centre of rect)
Is there any easy way to achieve this IsRectInRegion check?
As far as I can tell, I'd have to check for every points in this new rect along certain area intervals, but if someone would enlighten me to a better alternative, then it is most certainly welcomed.
Let's say we have a region with many rects in it such that all those rects do not overlap
Now if I want to add another rect into this region, say, [ljass] set r = Rect(minX, minY, maxX, maxY) [/ljass], how would I check if [ljass]r[/ljass] is in the region?
Intuitively, we could do:
JASS:
/*given*/ region g //with some existing rects
if IsPointInRegion(g, minX, minY)/*
*/ or IsPointInRegion(g, maxX, maxY)/*
*/ or IsPointInRegion(g, minX, maxY)/*
*/ or IsPointInRegion(g, maxX, minY)/*
effectively checking if any of the 4 corners is in the region*/ then
//pseudo-overlap detected
endif
But this test fails in 2 general cases as pictured below:
So this implies that simple point check is insufficient (i.e. check using 4 corners, check using centre of rect)
Is there any easy way to achieve this IsRectInRegion check?
As far as I can tell, I'd have to check for every points in this new rect along certain area intervals, but if someone would enlighten me to a better alternative, then it is most certainly welcomed.