Re: Covering rectangles in 2D
- From: quasi <quasi@xxxxxxxx>
- Date: Sat, 22 Mar 2008 02:26:32 -0500
On Sat, 22 Mar 2008 05:41:42 -0000, Tim Little
<tim@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
On 2008-03-22, quasi <quasi@xxxxxxxx> wrote:
But as far as I can see, you need to check every cell in a row (or
column), not just the one that generated the grid lines for that row
(or column).
Sort the x and y bounds of each rectangle, so that every rectangle is
associated with exactly two grid lines. (In the case of coinciding
grid lines, treat the grid cells between them as a region of zero area
which is not eligible for "uncovered" status)
Start at some cell. I chose the top left.
Do an O(N) check for how many rectangles cover that starting cell.
Keep track of this in a variable C that records the number of
rectangles covering the current cell.
Choose any path that covers the grid, crossing one grid line per step.
I chose a sweep back and forth: along each row, then down one cell,
then back along the next row in the opposite direction.
(Crossing any grid line gives the possibility of entering or leaving
at most the one, known, rectangle associated with that grid line.)
Check whether that rectangle boundary was actually crossed.
Increment, decrement, or leave C unchanged accordingly. This is an
O(1) operation.
If C = 0 for a cell with nonzero area, the area is not covered. If
instead the grid is exhausted, the area is covered.
If this is still too obscure, I could probably post code in some
programming language of your choice.
No, let me think about this.
Thanks.
quasi
.
- References:
- Re: Covering rectangles in 2D
- From: Tim Little
- Re: Covering rectangles in 2D
- From: quasi
- Re: Covering rectangles in 2D
- From: Tim Little
- Re: Covering rectangles in 2D
- From: quasi
- Re: Covering rectangles in 2D
- From: Tim Little
- Re: Covering rectangles in 2D
- From: quasi
- Re: Covering rectangles in 2D
- From: Tim Little
- Re: Covering rectangles in 2D
- From: quasi
- Re: Covering rectangles in 2D
- From: Tim Little
- Re: Covering rectangles in 2D
- Prev by Date: AAA Replica Louis Vuitton Louis Vuitton Monogram Multicolor Ursula M40124 Designer Handbags
- Next by Date: Re: algebra, factorization
- Previous by thread: Re: Covering rectangles in 2D
- Next by thread: Re: Covering rectangles in 2D
- Index(es):
Relevant Pages
|