27#define BIG_NUM (FLT_MAX / 4.0)
29#define Undefined(x, t) ((x)->boundary[0] > (x)->boundary[t->ndims_alloc])
113 for (i = 0; i <
t->ndims_alloc; i++)
114 r->boundary[i] =
r->boundary[i +
t->ndims_alloc] = (
RectReal)0;
232 r->boundary[
t->nsides_alloc - 1] = (
RectReal)-1;
233 for (i = 1; i <
t->ndims_alloc; i++)
234 r->boundary[i] =
r->boundary[i +
t->ndims_alloc] = (
RectReal)0;
251 for (i = 0; i <
NUMDIMS; i++) {
254 width =
drand48() * (1000 / 4) + 1;
258 r->boundary[i] =
drand48() * (1000 - width);
259 r->boundary[i +
NUMDIMS] =
r->boundary[i] + width;
281 for (i = 0; i <
NUMDIMS; i++) {
284 size = (
drand48() * (data->boundary[
j] -
285 data->boundary[i] + 1)) / 2;
287 (data->boundary[
j] - data->boundary[i] + 1);
313 for (i = 0; i <
t->ndims_alloc; i++) {
316 r->boundary[i +
t->ndims_alloc]);
334 for (i = 0; i <
t->ndims; i++)
335 volume *=
r->boundary[i +
t->ndims_alloc] -
r->boundary[i];
393#error "not enough precomputed sphere volumes"
395#define UnitSphereVolume UnitSphereVolumes[NUMDIMS]
419 for (i = 0; i <
t->ndims; i++) {
442 for (i = 0; i <
t->ndims; i++) {
443 extent = (
r->boundary[i +
t->ndims_alloc] -
r->boundary[i]);
466 for (i = 0; i <
t->ndims; i++) {
469 for (
j = 0;
j <
t->ndims;
j++)
490 for (i = 0; i <
t->ndims; i++) {
491 margin +=
r->boundary[i +
t->ndims_alloc] -
r->boundary[i];
508 for (i = 0; i <
t->nsides_alloc; i++)
509 r3->boundary[i] =
r2->boundary[i];
515 for (i = 0; i <
t->nsides_alloc; i++)
516 r3->boundary[i] =
r1->boundary[i];
521 for (i = 0; i <
t->ndims; i++) {
522 r3->boundary[i] =
MIN(
r1->boundary[i],
r2->boundary[i]);
523 j = i +
t->ndims_alloc;
524 r3->boundary[
j] =
MAX(
r1->boundary[
j],
r2->boundary[
j]);
526 for (i =
t->ndims; i <
t->ndims_alloc; i++) {
528 j = i +
t->ndims_alloc;
546 for (i = 0; i <
t->ndims; i++) {
547 if (
r1->boundary[i] >
r2->boundary[i]) {
548 r1->boundary[i] =
r2->boundary[i];
551 j = i +
t->ndims_alloc;
552 if (
r1->boundary[
j] <
r2->boundary[
j]) {
553 r1->boundary[
j] =
r2->boundary[
j];
558 for (i =
t->ndims; i <
t->ndims_alloc; i++) {
560 j = i +
t->ndims_alloc;
577 for (i = 0; i <
t->ndims; i++) {
578 j = i +
t->ndims_alloc;
596 for (i = 0; i <
t->ndims; i++) {
597 j = i +
t->ndims_alloc;
623 for (i = 0; i <
t->ndims; i++) {
624 j = i +
t->ndims_alloc;
648 for (i = 0; i <
t->ndims; i++) {
649 j = i +
t->ndims_alloc;
double sphere_volume(double dimension)
#define assert(condition)
struct RTree_Rect * RTreeAllocRect(struct RTree *t)
Create a new rectangle for a given tree.
void RTreeFreeRect(struct RTree_Rect *r)
Delete a rectangle.
void RTreeNullRect(struct RTree_Rect *r, struct RTree *t)
const double UnitSphereVolumes[]
void RTreeCombineRect(struct RTree_Rect *r1, struct RTree_Rect *r2, struct RTree_Rect *r3, struct RTree *t)
RectReal RTreeRectVolume(struct RTree_Rect *R, struct RTree *t)
void RTreeFreeBoundary(struct RTree_Rect *r)
Delete the boundary of a rectangle.
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.
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 RTreeInitRect(struct RTree_Rect *r, struct RTree *t)
Initialize a rectangle to have all 0 coordinates.
RectReal * RTreeAllocBoundary(struct RTree *t)
Allocate the boundary array of a rectangle for a given tree.
int RTreeContains(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
RectReal RTreeRectSurfaceArea(struct RTree_Rect *r, struct RTree *t)
int RTreeExpandRect(struct RTree_Rect *r1, struct RTree_Rect *r2, struct RTree *t)
RectReal RTreeRectMargin(struct RTree_Rect *r, struct RTree *t)
int RTreeOverlap(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
int RTreeContained(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
int RTreeCompareRect(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
void RTreePrintRect(struct RTree_Rect *R, int depth, struct RTree *t)
RectReal RTreeRectSphericalVolume(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.