27 #define BIG_NUM (FLT_MAX/4.0) 30 #define Undefined(x, t) ((x)->boundary[0] > (x)->boundary[t->ndims_alloc]) 31 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 32 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 153 double x_max,
double y_min,
double y_max)
178 double x_max,
double y_min,
double y_max,
double z_min,
208 double x_max,
double y_min,
double y_max,
double z_min,
209 double z_max,
double t_min,
double t_max)
254 for (i = 0; i < NUMDIMS; i++) {
257 width = drand48() * (1000 / 4) + 1;
261 r->
boundary[i] = drand48() * (1000 - width);
277 register struct RTree_Rect *search = Search, *data = Data;
284 for (i = 0; i < NUMDIMS; i++) {
286 if (data->boundary[i] > -
BIG_NUM && data->boundary[j] <
BIG_NUM) {
287 size = (drand48() * (data->boundary[j] -
288 data->boundary[i] + 1)) / 2;
289 center = data->boundary[i] + drand48() *
290 (data->boundary[j] - data->boundary[i] + 1);
291 search->
boundary[i] = center - size / 2;
292 search->
boundary[j] = center + size / 2;
315 fprintf(stdout,
"rect:\n");
336 for (i = 0; i < t->
ndims; i++)
359 double log_gamma, log_volume;
361 log_gamma = gamma(dimension / 2.0 + 1);
362 log_volume = dimension / 2.0 * log(
M_PI) - log_gamma;
363 return exp(log_volume);
395 # error "not enough precomputed sphere volumes" 397 #define UnitSphereVolume UnitSphereVolumes[NUMDIMS] 422 for (i = 0; i < t->
ndims; i++) {
424 if (c_size > maxsize)
427 return (
RectReal) (pow(maxsize / 2, NUMDIMS) *
438 double sum_of_squares = 0, extent;
445 for (i = 0; i < t->
ndims; i++) {
449 sum_of_squares += extent * extent / 4.;
469 for (i = 0; i < t->
ndims; i++) {
472 for (j = 0; j < t->
ndims; j++)
494 for (i = 0; i < t->
ndims; i++) {
526 for (i = 0; i < t->
ndims; i++) {
531 for (i = t->
ndims; i < t->ndims_alloc; i++) {
552 for (i = 0; i < t->
ndims; i++) {
564 for (i = t->
ndims; i < t->ndims_alloc; i++) {
583 for (i = 0; i < t->
ndims; i++) {
603 for (i = 0; i < t->
ndims; i++) {
631 for (i = 0; i < t->
ndims; i++) {
658 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)