示例#1
0
static inline bool
is_inside_right_area(struct touchpad *tp, struct touch *t)
{
	return is_inside_area(t, tp->buttons.config.top,
				 tp->buttons.config.bottom,
			         tp->buttons.config.right[0],
				 tp->buttons.config.right[1]);
}
示例#2
0
void MySimulation::update() {
    double xstep=2*(random()-0.5)*stepsize_;
    double ystep=2*(random()-0.5)*stepsize_;
    double x1=x_+xstep;
    double y1=y_+ystep;
    // Simple (not very efficient) way to make sure we are inside the area:
    if (!is_inside_area(x_,y_)) { // if we are now outside...
        x_=x1;
        y_=y1;
        return; // ...make a step and return without updating step count
    }
    // Simple-case Metropolis: always accept if we are within the area, always reject otherwise
    if (is_inside_area(x1,y1)) {
        x_=x1;
        y_=y1;
    }
    ++istep_;
}