示例#1
0
文件: R-tree.hpp 项目: Nerer/R-Tree
	double RecArea(const Rec &mbr)
	{
		if (!mbr.is_valid())
			return 0;
		static const double xpi = vratio(DIMENSION);
		double ret = 0;
		double sumr = 0;
		for (int i = 0; i < DIMENSION; i++)
		{
			double len = (mbr.bound[i + DIMENSION] - mbr.bound[i]) / 2;
			sumr += len * len;
		}
		double radius = sqrt(sumr);
		ret = pow(radius, DIMENSION) * xpi;
		return ret;
	}
示例#2
0
// Voronoi "value" is 0.0 (centre) to 1.0 (edge) if inside cell . . . higher values
// mean that point is not in the cell defined by chosen centre.
//  P is an array of points defining cell centres
//  n is number of points in array
//  q is chosen centre to measure distance from
//  U is point to test
double voronoi( double P[VORONOI_MAXPOINTS][2], int n, int q, double U[2] ) {
	double ratio;
	double ratiomax = -1.0e100;
	int i;

	for( i = 0; i < n; i++ ) {
		if ( i != q ) {
			ratio = vratio( P[i], P[q], U );
			if ( ratio > ratiomax ) {
				ratiomax = ratio;
			}
		}
	}

	return ratiomax;
}