#include <grid.h>
Public Member Functions | |
Grid () | |
constructor | |
~Grid () | |
destructor | |
void | clear () |
clear grid, erase all points | |
void | set (struct range x, struct range y) |
set gird resolution | |
void | info (ostream &os) const |
show infomation | |
void | insert (struct point p) |
insert point | |
size_t | size () const |
count number of points | |
void | occupied (ostream &os) const |
print number of points per grid square | |
int | average (struct rect range, struct point &p) const |
calculate average inside the given rectangle. | |
bool | bbox (struct range &rx, struct range &ry) const |
find bonding box | |
struct point * | closest (struct rect range, struct point &o) const |
find closest point | |
void | print (ostream &os) const |
print grid points | |
void | print (ostream &os, char *fmt) const |
print grid points using format string | |
Protected Attributes | |
struct node * | grid [MAXGRID][MAXGRID] |
grid array width fixed size | |
struct node * | z |
dummy tail node | |
struct point | origin |
origin | |
double | width |
grid width in x and y | |
Private Member Functions | |
void | check (struct point p1, struct point p2) |
compute distance and check if less than min | |
int | insiderect (struct point p, struct rect range) const |
check if inside rectangle | |
Private Attributes | |
double | min2 |
squared minimal distance | |
struct point cp1 | cp2 |
closest points | |
Classes | |
struct | node |
node definition More... |
Simple method for maintaining proximity relationship among points in a plane. An artificial grid divided an defined area in small rectagular cells. The points are keep in lists of points falling into each cell.
Reference: Robert Sedgewick, Algorithms in C++, Addision-Wesley Publishing Company, 1992.
calculate average inside the given rectangle.
by weighted distance (p=1/s^2) distance s = |dx| + |dy|
References GenLib2::point::c, grid, insiderect(), GenLib2::Grid::node::next, origin, GenLib2::Grid::node::p, width, GenLib2::point::x, GenLib2::rect::x1, GenLib2::rect::x2, GenLib2::point::y, GenLib2::rect::y1, GenLib2::rect::y2, and z.