Re: Box query

From: J M Davitt <jdavitt_at_aeneas.net>
Date: Sat, 22 Apr 2006 02:48:35 GMT
Message-ID: <7Qg2g.14661$mh.3014_at_tornado.ohiordc.rr.com>


Bob Badour wrote:

> J M Davitt wrote:
> 

>> Bob Badour wrote:
>>
>>> Mikito Harakiri wrote:
>>>
>>>> Mikito Harakiri wrote:
>>>>
>>>>> Given a set of n-dimensional boxes
>>>>>
>>>>> table boxes (
>>>>> dimension# integer,
>>>>> low integer,
>>>>> high integer
>>>>> )
>>>>>
>>>>> find all the pairs that intersect...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> And those pairs supposed to be what? Right, box ids:
>>>>
>>>> table boxes (
>>>> *id* integer,
>>>> dimension# integer,
>>>> low integer,
>>>> high integer
>>>> )
>>>>
>>>
>>> select b1.id as box1, b2.id as box2
>>> from boxes b1, boxes b2
>>> where b1.id < b2.id
>>> and not exists (
>>> select 1 from boxes b3, boxes b4
>>> where b3.id = b1.id
>>> and b4.id = b2.id
>>> and b4.dimension# = b3.dimension#
>>> and (b4.high < b3.low or b4.low > b3.high)
>>> )
>>> group by 1, 2
>>> ;
>>
>>
>>
>> Excellent! "not exists (no overlaps)." I like it. I was
>> thinking "exists (all overlap)."
>>
>> I think
>>
>> and (b4.high <= b3.low or b4.low >= b3.high)
>>
>> prevents responses where the boxes abut each other; although
>> not stated, I don't think that sharing part of an edge - even
>> a single point - means that boxes intersect. I'm guessing
>> the volume of the intersection s/b > 0.
> 
> 
> Does a point intersect with itself?

Sure. But I'm guessing that the intersection of a pair of boxes should be a box (not necessarily a cube) having non-zero volume.

Had the line segments on the axes been described as, say, closedopen  intervals - like {a, <x, [0,2)>, <y [0,2)>, <z, [0,2]>} - there would be no discussion. But they weren't, and we're trying to decide whether a point is the same as box with edges of length zero. Received on Sat Apr 22 2006 - 04:48:35 CEST

Original text of this message