RTree源代码——C语言实现(下)2010-10-29 csdn 张亮/*============================================================================= Public functions: =============================================================================*/
int RTreeSetNodeMax(int new_max) { return set_max(&NODECARD, new_max); } int RTreeSetLeafMax(int new_max) { return set_max(&LEAFCARD, new_max); } int RTreeGetNodeMax(void) { return NODECARD; } int RTreeGetLeafMax(void) { return LEAFCARD; }
/** * Initialize a rectangle to have all 0 coordinates. */ void RTreeInitRect( RTREEMBR *rc) { int i; for (i=0; i<SIDES_NUMB; i++) rc->bound[i] = (REALTYPE) 0; }
/** * Return a mbr whose first low side is higher than its opposite side - * interpreted as an undefined mbr. */ RTREEMBR RTreeNullRect(void) { RTREEMBR rc; int i;
/** * Calculate the n-dimensional volume of the bounding sphere of a rectangle. * The exact volume of the bounding sphere for the given RTREEMBR. */ REALTYPE RTreeRectSphericalVolume( RTREEMBR *rc ) { int i; double sum_of_squares=0, radius;
/** * Calculate the n-dimensional surface area of a rectangle */ REALTYPE RTreeRectSurfaceArea( RTREEMBR *rc ) { int i, j; REALTYPE sum = (REALTYPE) 0;
if (INVALID_RECT(rc)) return (REALTYPE) 0;
for (i=0; i<DIMS_NUMB; i++) { REALTYPE face_area = (REALTYPE)1; for (j=0; j<DIMS_NUMB; j++) /* exclude i extent from product in this dimension */ if(i != j) { REALTYPE j_extent = rc->bound[j+DIMS_NUMB] - rc->bound[j]; face_area *= j_extent; } sum += face_area; } return 2 * sum; }