Пример #1
0
float Cylinder::nhs(const Cylinder &c) const
{
	int hamming = 0;
	const float P = 30;

	if (abs(dFi(getrT(),c.getrT())) > 0.785398163397 || dss(c.getX(), c.getY()) > DELTAXY*DELTAXY)
		return 0;
	
	for(unsigned int i = 0; i < NUMCELLS; ++i)
		if (getB1(i) != c.getB1(i))
			hamming++;
		
	return pow(1.0-((float)hamming)/NUMCELLS, P);
}
Пример #2
0
float Cylinder::similarity(const Cylinder & c) const
{
	unsigned int count = 0;
	float norma_b = 0, normb_a = 0, norm_diff = 0;
	float ca_b, cb_a;

	if (abs(dFi(getrT(),c.getrT())) > DELTAZETA)
		return 0;
	
	if (bit == false)
	{
		for (unsigned int i=0; i<NUMCELLS; i++)
		{
			ca_b = cmVector[i];
			cb_a = c.getCM(i);

			if (ca_b>=0 && cb_a>=0)
			{
				count++;

				norma_b += ca_b*ca_b;
				normb_a += cb_a*cb_a;
				norm_diff += ca_b*cb_a;
			}
		}

		//Check if two cylinders are matchable
		if(count >= MINCELLS)
		{
			norm_diff = sqrt(norma_b + normb_a - 2.0*norm_diff);
			return 1.0 - (norm_diff/(sqrt(norma_b)+sqrt(normb_a)));
		}
		else
			return 0;
	}
	else
	{
		int counta_b = 0, countb_a = 0, count_diff = 0;

		for (unsigned int i=0; i<cmBit1.size(); ++i)
			if (getB2(i) && c.getB2(i))
			{
				count++;
				
				if (getB1(i))
				{
					counta_b++;
					
					if(!c.getB1(i))
						count_diff++;
				}
				
				if (c.getB1(i))
				{
					countb_a++;
					
					if(!getB1(i))
						count_diff++;
				}
			}
		
		//Check if two cylinders are matchable
		if (count >= MINCELLS)
			return (1 - (sqrt(count_diff)/(sqrt(counta_b)+sqrt(countb_a))));
		else
			return 0;
	}
}