[OT] Poll: What does it mean for 1 rect to be 'within' a certain distance of another rect?

Alex Tweedly alex at tweedly.net
Tue Feb 16 14:46:11 EST 2021


Paul - if you need to do this (i.e. find pairs of rects which are too 
close) for LARGE numbers of rects, I have some code to do this very 
efficiently (somewhere in an old archive, just ready to translate from C 
to LC). It uses a 'trailing window horizontal scan' so reduces the 
complexity/time from N^2 to N log N

Alex.

On 16/02/2021 18:27, Paul Dupuis via use-livecode wrote:
> On 2/15/2021 5:53 PM, Paul Dupuis via use-livecode wrote:
>> This is an Off Topic informal poll of sorts, but related to LiveCode 
>> as I am writing a LiveCode expression to determine if 2 arbitrary 
>> rectangles (r1,r2) are with some distance d (in px) of one another. 
>> In considering this problem, the questions comes up: What is meant by 
>> rectangles being within a distance d of one another. What is the 'd' 
>> measured from?
>>
>> center to center? Easiest is many ways, but I don't think this is 
>> what most people would think of.
>>
>> adjacent edge to adjacent edge? This is harder (I think), but I think 
>> this is what more people intuitively think of. To me, implicit in the 
>> visual concept of 2 rects being within some distance of one another 
>> is that they are NOT overlapping, but that some gap exists between 
>> the nearest adjacent edges?
>>
>> Something else? What does 2 rects  being 'within' d pixels of one 
>> another mean to you, if not one of the two above options?
>>
>> Maybe there is a exact mathematical definition of what 2 rectangles 
>> being within distance d of one another is, but, if there is, I am 
>> unfamiliar with it.
>
>
> Okay, Poll Closed!
>
> Thank you everyone. I think the responses (informal as this is) 
> confirms the majority fo people think of distance between 2 rectangles 
> as the distance between nearest edges or vertices which is the same as 
> saying the *smallest* distance between any two points in the rects 
> (mathematically)
>
> I appreciate all the responses! (and the links and code examples!)
>
> -- Paul
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list