Ejemplo n.º 1
0
//! Interpolate scale-space extrema to subpixel accuracy to form an image feature. 
void interpolateExtremum(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, FastHessian *fh)
{
	double xi = 0, xr = 0, xc = 0;

	// get the step distance between filters
	// check the middle filter is mid way between top and bottom
	
	int filterStep = (m->filter - b->filter);
	assert(filterStep > 0 && t->filter - m->filter == m->filter - b->filter);

	// Get the offsets to the actual location of the extremum
	interpolateStep(r, c, t, m, b, &xi, &xr, &xc );

	if( fabs( xi ) < 0.5f  &&  fabs( xr ) < 0.5f  &&  fabs( xc ) < 0.5f )
	{
		Ipoint ipt;
		ipt.x = (float)((c + xc) * t->step);
		ipt.y = (float)((r + xr) * t->step);
		ipt.scale = (float)((0.1333f) * (m->filter + xi * filterStep));
		ipt.laplacian = (int)(getLaplacian(r,c,t,m));
		fh->ipts[count] = ipt;
		count++;
	}
	
}
tarch::la::Vector<DIMENSIONS,double> LaplacianBasedForceCalculator::computeForces(
		services::ParticlesProxy& particle,
		tarch::la::Vector<DIMENSIONS,double>& particlesVelocity){
	static std::ofstream flog("forces.log");
	static int count;
	count++;
	double radius = particle.radius;
	double viscosity = services::ParticlesService::getInstance().getViscosity();

	tarch::la::Vector<DIMENSIONS, double> force;

	// first order forces (Faxen correction)
	double* laplacian = getLaplacian(particle);
	force[0] = tarch::la::PI*viscosity*radius
			*(6*(particle.velocities[0][0]-particlesVelocity[0])
					+ /*radius*radius**/laplacian[0]);
	force[1] = tarch::la::PI*viscosity*radius
			*(6*(particle.velocities[0][1]-particlesVelocity[1])
					+ /*radius*radius**/laplacian[1]);

	flog << count << std::endl;
	flog << "PI: " << tarch::la::PI << std::endl;
	flog << "viscosity: " << viscosity << std::endl;
	flog << "radius: " << radius << std::endl;
	flog << "l: " << laplacian[0] << " : " << laplacian[1] << std::endl;
	flog << "f: " << force[0] << " : " << force[1] << std::endl;
	flog << "vp: " << particlesVelocity[0] << " : " << particlesVelocity[1] << std::endl;
	flog << "vf: " << particle.velocities[0][0] << " : " << particle.velocities[0][1] << std::endl;
	flog << "u01234: " << particle.velocities[0][0] << " : " <<particle.velocities[1][0] << " : "
			<< particle.velocities[2][0] << " : " << particle.velocities[3][0] << " : "
			<< particle.velocities[4][0] << std::endl;
	flog << "v01234: " << particle.velocities[0][1] << " : " <<particle.velocities[1][1] << " : "
			<< particle.velocities[2][1] << " : " << particle.velocities[3][1] << " : "
			<< particle.velocities[4][1] << std::endl;

	delete[] laplacian;

	return force;
}