Beispiel #1
0
int
grid::closest_point(const vector& r) const {
  int i;
  int j;
  int k;
  i = closest_int((r(1)-lbnd[0])/spacing);
  j = closest_int((r(2)-lbnd[1])/spacing);
  k = closest_int((r(3)-lbnd[2])/spacing);
  return array2index(i,j,k);
}
int CyclesForBallToPoint(Vector pt, float targ_vel_at_pt, float max_kick_speed, 
			 Vector mypos, float ball_decay)
{
  if (targ_vel_at_pt < FLOAT_EPS) 
    my_error("Shouldn't call CyclesForBallToPoint with ~0 targ_vel: %f", targ_vel_at_pt);
  float kick_spd = Min(max_kick_speed,
		       VelAtPt2VelAtFoot_sh(pt, targ_vel_at_pt, mypos, ball_decay));
  float steps = SolveForLengthGeomSeries(kick_spd, ball_decay, mypos.dist(pt));
  return (steps < 0 ? -1 : closest_int(steps));  
}
int kick_time_helper(Vector start, Vector end, float targ_vel_at_pt,
		     float max_kick_speed, int cycles_to_kick)
{
  float init_vel = VelAtPt2VelAtFoot_sh(end, targ_vel_at_pt, start, 
					Mem->SP_ball_decay);
  init_vel = Min(init_vel, max_kick_speed);
  int num_cycles = closest_int(ceil(SolveForLengthGeomSeries(init_vel, 
							     Mem->SP_ball_decay, 
							     start.dist(end))));
  num_cycles += cycles_to_kick;
  
  return num_cycles;
}