Esempio n. 1
0
void Crowd::binsort()
{
	int i,j,k,l;
	double ndiv,factx,facty,factz;
	deque<int> ibin;
	Node* nd;
	int num;

	/*////
	   double stx,sty,stz;
	   stx = stdpt.getX()/stdrate;
	   sty = stdpt.getY()/stdrate;
	   stz = stdpt.getZ()/stdrate;
	 */                                                                                                                    /////

	///binlist.clear();
	num = getSize();
	///for(i=0;i<num;i++) binlist.push_back(i);

	ndiv = (int)pow((double)num,0.1);
	factx = ndiv / ((getXWidth()) * 1.01 / getMaxWidth());
	facty = ndiv / ((getYWidth()) * 1.01 / getMaxWidth());
	factz = ndiv / ((getZWidth()) * 1.01 / getMaxWidth());

	for(l = 0; l < num; l++)
	{
		nd = getNode(l);
		i = (int)((nd->getX()) * factx);
		j = (int)((nd->getY()) * factz);
		k = (int)((nd->getZ()) * facty);
		//////
		//i = (int)((nd->getX()-stx)*factx);
		//j = (int)((nd->getY()-sty)*factz);
		//k = (int)((nd->getZ()-stz)*facty);
		///////////
		if((k % 2) == 0)
		{
			if((j % 2) == 0)
				ibin.push_back((int)(k * ndiv * ndiv + j * ndiv + i + 1));
			else
				ibin.push_back((int)(k * ndiv * ndiv + (j + 1) * ndiv - i));
		}
		else
		{
			if((j % 2) == 0)
				ibin.push_back((int)(k * ndiv * ndiv + (ndiv - j) * ndiv - i));
			else
				ibin.push_back((int)(k * ndiv * ndiv +
				                     (ndiv - j - 1) * ndiv + i + 1));
		}
	}

	dtm::quickSort(0,num - 1,binlist,ibin);
}
Esempio n. 2
0
float AABoundingBox::getVolume() const { return getXWidth() * getYWidth() * getZWidth(); }