28 #define BIG_NUM (FLT_MAX/4.0) 31 #define Undefined(x, t) ((x)->boundary[0] > (x)->boundary[t->ndims_alloc]) 152 double x_max,
double y_min,
double y_max)
177 double x_max,
double y_min,
double y_max,
double z_min,
207 double x_max,
double y_min,
double y_max,
double z_min,
208 double z_max,
double t_min,
double t_max)
253 for (i = 0; i < NUMDIMS; i++) {
256 width = drand48() * (1000 / 4) + 1;
260 r->
boundary[i] = drand48() * (1000 - width);
276 register struct RTree_Rect *search = Search, *data = Data;
283 for (i = 0; i < NUMDIMS; i++) {
285 if (data->boundary[i] > -
BIG_NUM && data->boundary[j] <
BIG_NUM) {
286 size = (drand48() * (data->boundary[j] -
287 data->boundary[i] + 1)) / 2;
288 center = data->boundary[i] + drand48() *
289 (data->boundary[j] - data->boundary[i] + 1);
290 search->
boundary[i] = center - size / 2;
291 search->
boundary[j] = center + size / 2;
314 fprintf(stdout,
"rect:\n");
335 for (i = 0; i < t->
ndims; i++)
358 double log_gamma, log_volume;
360 log_gamma = gamma(dimension / 2.0 + 1);
361 log_volume = dimension / 2.0 * log(
M_PI) - log_gamma;
362 return exp(log_volume);
394 # error "not enough precomputed sphere volumes" 396 #define UnitSphereVolume UnitSphereVolumes[NUMDIMS] 421 for (i = 0; i < t->
ndims; i++) {
423 if (c_size > maxsize)
426 return (
RectReal) (pow(maxsize / 2, NUMDIMS) *
437 double sum_of_squares = 0, extent;
444 for (i = 0; i < t->
ndims; i++) {
448 sum_of_squares += extent * extent / 4.;
468 for (i = 0; i < t->
ndims; i++) {
471 for (j = 0; j < t->
ndims; j++)
493 for (i = 0; i < t->
ndims; i++) {
525 for (i = 0; i < t->
ndims; i++) {
530 for (i = t->
ndims; i < t->ndims_alloc; i++) {
551 for (i = 0; i < t->
ndims; i++) {
563 for (i = t->
ndims; i < t->ndims_alloc; i++) {
582 for (i = 0; i < t->
ndims; i++) {
602 for (i = 0; i < t->
ndims; i++) {
630 for (i = 0; i < t->
ndims; i++) {
657 for (i = 0; i < t->
ndims; i++) {
RectReal RTreeRectVolume(struct RTree_Rect *R, struct RTree *t)
void RTreeSetRect2D(struct RTree_Rect *r, struct RTree *t, double x_min, double x_max, double y_min, double y_max)
Set two dimensional coordinates of a rectangle for a given tree.
void RTreeSetRect4D(struct RTree_Rect *r, struct RTree *t, double x_min, double x_max, double y_min, double y_max, double z_min, double z_max, double t_min, double t_max)
Set 4 dimensional coordinates of a rectangle for a given tree.
void RTreeNullRect(struct RTree_Rect *r, struct RTree *t)
void RTreeSetRect1D(struct RTree_Rect *r, struct RTree *t, double x_min, double x_max)
Set one dimensional coordinates of a rectangle for a given tree.
RectReal RTreeRectMargin(struct RTree_Rect *r, struct RTree *t)
void RTreeSetRect3D(struct RTree_Rect *r, struct RTree *t, double x_min, double x_max, double y_min, double y_max, double z_min, double z_max)
Set three dimensional coordinates of a rectangle for a given tree.
double sphere_volume(double dimension)
unsigned char ndims_alloc
#define assert(condition)
void RTreeFreeBoundary(struct RTree_Rect *r)
Delete the boundary of a rectangle.
const double UnitSphereVolumes[]
RectReal RTreeRectSphericalVolume(struct RTree_Rect *r, struct RTree *t)
void RTreeFreeRect(struct RTree_Rect *r)
Delete a rectangle.
void RTreeCombineRect(struct RTree_Rect *r1, struct RTree_Rect *r2, struct RTree_Rect *r3, struct RTree *t)
unsigned char nsides_alloc
RectReal * RTreeAllocBoundary(struct RTree *t)
Allocate the boundary array of a rectangle for a given tree.
void RTreeInitRect(struct RTree_Rect *r, struct RTree *t)
Initialize a rectangle to have all 0 coordinates.
struct RTree_Rect * RTreeAllocRect(struct RTree *t)
Create a new rectangle for a given tree.
int RTreeExpandRect(struct RTree_Rect *r1, struct RTree_Rect *r2, struct RTree *t)
int RTreeCompareRect(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
int RTreeContains(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
RectReal RTreeRectSurfaceArea(struct RTree_Rect *r, struct RTree *t)
int RTreeOverlap(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
void RTreePrintRect(struct RTree_Rect *R, int depth, struct RTree *t)
int RTreeContained(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)