search.cpan.org is shutting down
Salvador Fandiño García > Algorithm-RectanglesContainingDot-0.02 > Algorithm::RectanglesContainingDot
Module Version: 0.02

# NAME

Algorithm::RectanglesContainingDot - find rectangles containing a given dot

# SYNOPSIS

```  use Algorithm::RectanglesContainingDot;

my \$alg = Algorithm::RectanglesContainingDot->new;

for my \$i (0 .. \$num_rects) {
}

for my \$j (0 .. \$num_points) {
my @rects_containing_dot_names = \$alg->rectangles_containing_dot(\$px[\$j], \$py[\$j]);
...
}```

# DESCRIPTION

Given a set of rectangles and a set of dots, the algorithm implemented in this modules finds for every dot, which rectangles contain it.

The algorithm complexity is O(R * log(R) * log(R) + D * log(R)) being R the number of rectangles and D the number of dots.

Its usage is very simple:

1) create and algorithm object:
`    \$a = Algorithm::RectanglesContainingDot->new;`
`    \$a->add_rectangle(\$name, \$x0, \$y0, \$x1, \$y1);`

Rectangles are identified by a name that can be any perl scalar (typically an integer or a string).

(\$x0, \$y0) and (\$x1, \$y1) correspond to the coordinates of the left-botton and right-top vertices respectively.

3) call the search method for every dot:
`    @rects = \$a->rectangles_containing_dot(\$x, \$y)`

Returns the names of the rectangles containing the dot (\$x, \$y).

Algorithm::RectanglesContainingDot_XS implements the same algorithm as this module in C/XS and so it is much faster. When available, this module will automatically load and use it.