Re: Algorithm to identify area in common?
- From: Tim Rentsch <txr@xxxxxxxxxxxxxxxxxxx>
- Date: 30 Apr 2005 14:03:18 -0700
"No Such Luck" <no_suchluck@xxxxxxxxxxx> writes:
> > > 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?
> >
If we have a lower left corner and an upper right corner, using the
normal Cartesian coordinate system (x increasing to the right, y
increasing up), and the rectangles are { (ax1,ay1) , (ax2,ay2) }
and { (bx1,by1) , (bx2,by2) }, then
The lower left corner of the intersection box is
( MAX( ax1, bx1 ), MAX( ay1, by1 ) )
Similarly the upper right corner of the intersection box is
( MIN( ax2, bx2 ), MIN( ay2, by2 ) )
I expect you can make suitable adjustments for the coordinate
system you're using.
.
- References:
- Algorithm to identify area in common?
- From: No Such Luck
- Re: Algorithm to identify area in common?
- From: Thad Smith
- Re: Algorithm to identify area in common?
- From: No Such Luck
- Algorithm to identify area in common?
- Prev by Date: Re: Algorithm to identify area in common?
- Next by Date: Re: Algorithm to identify area in common?
- Previous by thread: Re: Algorithm to identify area in common?
- Next by thread: How to clear cache on my Browsewr?. What happens if I am not clearing?
- Index(es):
Relevant Pages
|