コード例 #1
0
ファイル: ScrollBar.cpp プロジェクト: pedia/raidget
Rect ScrollBar::GetPartRect(int p) const {
	Rect h = Slider();
	int sbo = style->overthumb;
	int off = GetHV(h.left, h.top);
	int ts = thumbsize;
	if(ts < style->thumbmin)
		ts = 0;
	switch(p) {
	case 0:
		HV(h.right, h.bottom) = thumbpos - sbo + ts / 2 + off;
		break;
	case 1:
		HV(h.left, h.top) = thumbpos + ts / 2 + sbo + off;
		break;
	case 2:
		HV(h.left, h.top) = thumbpos - sbo + off;
		HV(h.right, h.bottom) = thumbpos + ts + sbo + off;
		break;
	}
	return h;
}
コード例 #2
0
ファイル: project.cpp プロジェクト: metorm/libigl
IGL_INLINE void igl::project(
  const    Eigen::MatrixBase<DerivedV>&  V,
  const    Eigen::MatrixBase<DerivedM>& model,
  const    Eigen::MatrixBase<DerivedN>& proj,
  const    Eigen::MatrixBase<DerivedO>&  viewport,
  Eigen::PlainObjectBase<DerivedP> & P)
{
  typedef typename DerivedP::Scalar PScalar;
  Eigen::Matrix<PScalar,DerivedV::RowsAtCompileTime,4> HV(V.rows(),4);
  HV.leftCols(3) = V.template cast<PScalar>();
  HV.col(3).setConstant(1);
  HV = (HV*model.template cast<PScalar>().transpose()*
      proj.template cast<PScalar>().transpose()).eval();
  HV = (HV.array().colwise()/HV.col(3).array()).eval();
  HV = (HV.array() * 0.5 + 0.5).eval();
  HV.col(0) = (HV.array().col(0) * viewport(2) + viewport(0)).eval();
  HV.col(1) = (HV.array().col(1) * viewport(3) + viewport(1)).eval();
  P = HV.leftCols(3);
}
コード例 #3
0
ファイル: controller.cpp プロジェクト: degoldcode/NaviSim
double Controller::update(Angle angle, double speed, double inReward, vec inLmr, int color) {
	if(t%inv_sampling_rate == 0 && !SILENT){
		pi_array = join_rows(pi_array, pin->get_output());
		if(gvlearn_on){
			gv_array = join_rows(gv_array, gvl->w(0));
		}
		if(lvlearn_on){
			for(int i = 0; i < lv_array.size(); i++)
				lv_array.at(i) = join_rows(lv_array.at(i), lvl->w(i));
			ref_array = join_rows(ref_array, lvl->RefPI());
		}
	}
	t++;

	/*** Check, if inward ***/
	if(t > t_home || accum_reward(0) > 1.){
		inward = 1.;
		//printf("t= %u > %u or sum(R)= %g\n", t, t_home, accum_reward(0));
	}

	/*** Path Integration Mechanism ***/
	if(pin_on)
		pin->update(angle, speed);

	if(gvlearn_on && gl_w > 0.)
		pi_w = HV().len() * (1. - expl_factor(0))*(1.-accu(lv_value));
	else
		pi_w = 0.0;
	pi_m =  ((HV().ang()).i() - angle).S();		//NEW PI COMMAND
	if(homing_on && inward!=0.){
		//printf("this should not be! %g\n", inward);
		pi_w = 0.5;
		pi_m = ((HV().ang()).i() - angle).S();
		rand_m = 0.0;//0.25;
	}
	if(pi_w < 0.)
		pi_w = 0.;
	output_hv = pi_w * pi_m;



	/*** Reward and value update ***/
	if(lvlearn_on){
		for(int i = 0; i < num_lv_units; i++)
			lv_value(i) = 1. - exp(-0.5*lvl->eligibility_value(i));
	}
	delta_beta = mu_beta*((1./expl_beta) + lambda * value(0) * expl_factor(0));
	if(beta_on)
		expl_beta += delta_beta;
	if(expl_factor(0) < 0.0001 && delta_beta < 0.01)
		beta_on = false;

	for(int i = 0; i < num_colors; i++){
		if(i == color){
			reward(i) = inReward;
			if(inward==0.){
				value(i) = (reward(i) /*+ accu(lv_value)*/) + disc_factor * value(i);
				if(!const_expl)
					expl_factor(i) = exp(- expl_beta * value(i));
				else
					expl_factor(i) += d_expl_factor(i);
				expl_factor.elem( find(expl_factor > 1.) ).ones();    //clip expl
				expl_factor.elem( find(expl_factor < 0.) ).zeros();   //clip expl
			}
		}
		else{
			reward(i) = 0.0;
		}
	}
	accum_reward += reward;

	/*** Global Vector Learning Circuits TODO ***/
	if(gvlearn_on){
		for(int i = 0; i < num_colors; i++){
			gvl->update(pin->get_output(), reward(i), expl_factor(i));
			cGV.at(i) = (GV(i) - HV());
		}

		gl_w = (1. - inward)*GV(0).len() * (1.-expl_factor(0));
		gl_m = (GV(0).ang() - angle).S();			//NEW GV COMMAND
	}
	//stream << cGV.at(0).ang().deg() << endl;
	output_gv = gl_w * gl_m;

	/*** Local Vector Learning Circuits TODO ***/
	if(lvlearn_on){

		lvl->update(angle, speed, inReward, inLmr);

		rl_m = 0.0;
		rl_w = (1. - inward);
		for(int i = 0; i < num_lv_units; i++){
			//cLV.at(i) = (LV(i) - HV());
			if(inward == 0.){
				gl_w = 0.0;
				pi_w = 0.0;
				rl_m += lv_value(i) * (LV().len()*(LV().ang() - angle).S() + RV().len()*(RV().ang().i() - angle).S());
			}
		}
		//if(VERBOSE && t%100==0)
			//printf("t = %u\tHV = (%f, %f)\tLV = (%f, %f)\tRV = (%f, %f)\n", t, HV().ang().deg(), HV().len(), LV().ang().deg(), LV().len(), RV().ang().deg(), RV().len());
		output_lv = rl_w * rl_m;
	}
	else
		output_lv = 0.;

	/*** Random foraging ***/
	if(lvlearn_on){
		rand_w = (1. - inward)*0.6*expl_factor(0)*(1.-accu(lv_value));
	}
	else
		rand_w = (1. - inward)*0.6*expl_factor(0);
	rand_m = randn(0.0, 1.);
	if(inward == 1)
		rand_m = 0.;

	output_rand = rand_w * rand_m;

	/*** Navigation Control Output ***/
	output = output_rand + output_hv + output_gv + output_lv;
	//output = output_rand + output_hv + 0.0 + output_lv; // Route formation

	return output;
}
コード例 #4
0
	RequestParameters HVconfigEntry::params_to_insert() const{
		return {to_string(HVPMConnection_id()),to_string(HV())};
	}