Re: Algorithm to identify area in common?
- From: "No Such Luck" <no_suchluck@xxxxxxxxxxx>
- Date: 30 Apr 2005 12:54:18 -0700
> > Suppose I have two rectangles existing in space (memory), and these
two
>> rectangles are represented by their bounding box coorinates: top
left
>> corner (x1, y1), bottom right corner (x2, y2). Is there an algorithm
>> that, when given the bounding box cooridinates of two of these
>> rectangles, will return the union of the areas of the rectangles, in
>> square units?
>
>Yes, there are techniques for that. I suggest trying to work out a
>technique on paper. There will be several cases that you need to
>consider. If you then get stuck with your homework problem, post what
>you have done and what particular problem you are having.
I haven't had a homework assignment in over 5 years, thank you.
What I have worked out so far is:
We know the rectangles do not overlap in any way if:
- both x's from rectangle 1 are less than or greater than the x's of
rectangle 2, OR
- both y's from rectangle 1 are less than or greater than the y's of
rectangle 2
So inversely, we can assume there is an interection if the above
condition fails.
At this point, I only really need to know if there is an area of
intersection (i.e, a boolean "yes" or "no"). Down the road, though,
knowing the exact amount of overlap may be useful, which it the part I
am having trouble with.
.
- Follow-Ups:
- Re: Algorithm to identify area in common?
- From: Tim Rentsch
- Re: Algorithm to identify area in common?
- References:
- Algorithm to identify area in common?
- From: No Such Luck
- Re: Algorithm to identify area in common?
- From: Thad Smith
- Algorithm to identify area in common?
- Prev by Date: How to clear cache on my Browsewr?. What happens if I am not clearing?
- Next by Date: Re: Algorithm to identify area in common?
- Previous by thread: Re: Algorithm to identify area in common?
- Next by thread: Re: Algorithm to identify area in common?
- Index(es):
Relevant Pages
|