Something like IsRectInRegion

Moradiae

TH.net Regular
Reaction score
14
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:
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:

scaled.php


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. :)
 

Moradiae

TH.net Regular
Reaction score
14
Oh, right..
lol couldn't believe it would be so simple

thank you, Dirac :)

[ljass]//------------------------------------------[/ljass]
[ljass]//edit[/ljass]

oh but then that blue rectangle on the right could be taller so that the top 2 corners are outside the orange rect and then we'll be back to the same problem :(

Thanks for the input anyway, but I guess I'll just stick with the check over some small area interval.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top