24#define BIG_NUM (FLT_MAX / 4.0)
26#define Undefined(x, t) ((x)->boundary[0] > (x)->boundary[t->ndims_alloc])
110 for (i = 0; i <
t->ndims_alloc; i++)
111 r->boundary[i] =
r->boundary[i +
t->ndims_alloc] = (
RectReal)0;
229 r->boundary[
t->nsides_alloc - 1] = (
RectReal)-1;
230 for (i = 1; i <
t->ndims_alloc; i++)
231 r->boundary[i] =
r->boundary[i +
t->ndims_alloc] = (
RectReal)0;
248 for (i = 0; i <
NUMDIMS; i++) {
251 width =
drand48() * (1000 / 4) + 1;
255 r->boundary[i] =
drand48() * (1000 - width);
256 r->boundary[i +
NUMDIMS] =
r->boundary[i] + width;
278 for (i = 0; i <
NUMDIMS; i++) {
281 size = (
drand48() * (data->boundary[
j] -
282 data->boundary[i] + 1)) / 2;
284 (data->boundary[
j] - data->boundary[i] + 1);
310 for (i = 0; i <
t->ndims_alloc; i++) {
313 r->boundary[i +
t->ndims_alloc]);
331 for (i = 0; i <
t->ndims; i++)
332 volume *=
r->boundary[i +
t->ndims_alloc] -
r->boundary[i];
390#error "not enough precomputed sphere volumes"
392#define UnitSphereVolume UnitSphereVolumes[NUMDIMS]
416 for (i = 0; i <
t->ndims; i++) {
439 for (i = 0; i <
t->ndims; i++) {
440 extent = (
r->boundary[i +
t->ndims_alloc] -
r->boundary[i]);
463 for (i = 0; i <
t->ndims; i++) {
466 for (
j = 0;
j <
t->ndims;
j++)
487 for (i = 0; i <
t->ndims; i++) {
488 margin +=
r->boundary[i +
t->ndims_alloc] -
r->boundary[i];
505 for (i = 0; i <
t->nsides_alloc; i++)
506 r3->boundary[i] =
r2->boundary[i];
512 for (i = 0; i <
t->nsides_alloc; i++)
513 r3->boundary[i] =
r1->boundary[i];
518 for (i = 0; i <
t->ndims; i++) {
519 r3->boundary[i] =
MIN(
r1->boundary[i],
r2->boundary[i]);
520 j = i +
t->ndims_alloc;
521 r3->boundary[
j] =
MAX(
r1->boundary[
j],
r2->boundary[
j]);
523 for (i =
t->ndims; i <
t->ndims_alloc; i++) {
525 j = i +
t->ndims_alloc;
543 for (i = 0; i <
t->ndims; i++) {
544 if (
r1->boundary[i] >
r2->boundary[i]) {
545 r1->boundary[i] =
r2->boundary[i];
548 j = i +
t->ndims_alloc;
549 if (
r1->boundary[
j] <
r2->boundary[
j]) {
550 r1->boundary[
j] =
r2->boundary[
j];
555 for (i =
t->ndims; i <
t->ndims_alloc; i++) {
557 j = i +
t->ndims_alloc;
574 for (i = 0; i <
t->ndims; i++) {
575 j = i +
t->ndims_alloc;
593 for (i = 0; i <
t->ndims; i++) {
594 j = i +
t->ndims_alloc;
620 for (i = 0; i <
t->ndims; i++) {
621 j = i +
t->ndims_alloc;
645 for (i = 0; i <
t->ndims; i++) {
646 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.