Algorithm to identify area in common?
- From: "No Such Luck" <no_suchluck@xxxxxxxxxxx>
- Date: 30 Apr 2005 09:23:05 -0700
Hi All:
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?
Example 1:
Rectangle 1: (1, 2), (4, 7)
Rectangle 2: (6, 1), (8, 3)
Answer: 0 square units in common
Example 2:
Rectangle 1: (1, 2), (4, 7)
Rectangle 2: (4, 1), (7, 9)
Answer: 6 square units in common (these rectangles share a line)
Example 3:
Rectangle 1: (1, 2), (4, 7)
Rectangle 2: (2, 3), (6, 5)
Answer: 9 square units in common (a clear overlap)
Thanks for any input.
.
- Follow-Ups:
- Re: Algorithm to identify area in common?
- From: Thad Smith
- Re: Algorithm to identify area in common?
- Prev by Date: Re: Writing a character to the beginning of the same file
- Next by Date: How to clear cache on my Browsewr?. What happens if I am not clearing?
- Previous by thread: Speaking of the programming job market...
- Next by thread: Re: Algorithm to identify area in common?
- Index(es):
Relevant Pages
|