interception.cpp
来自「robocup3d源化码 Nexus3D.tar.gz」· C++ 代码 · 共 55 行
CPP
55 行
/*Copyright (C) 2005 Ferdowsi University*/#include "interception.h"#include "global.h"Intercept::Intercept(){ }bool Intercept::TryIntercept(){ Vector3f target; target[2] = self.pos[2]; if(ball.vel.Length() > 0.5 && ball.distance > 0.5){ for(int i = 1; i<12; i++) { if(i != MyNumber && (MyPlayer[i].pos-predicted_ball_pos[stop_index]).Length() < (self.pos-predicted_ball_pos[stop_index]).Length() - 0.01) return false; } DoLog(LOG_INTERCEPT,"using prediction,interception done"); target[0] = predicted_ball_pos[stop_index][0]; target[1] = predicted_ball_pos[stop_index][1]; } else{ for(int i = 1; i<12; i++) { if(i != MyNumber && MyPlayer[i].dist2ball < ball.distance - 0.01) return false; } DoLog(LOG_INTERCEPT,"interception done"); target[0] = ball.pos[0]; target[1] = ball.pos[1]; } if((self.pos - target).Length() > 1 && ball.vel.Length() < 2) { float angle = NormalizeAngle(Rad2Deg(atan2((0 - target[1]),(FieldLength/2 - target[0]))),-180.0); Vector3f pos = AdjustKickPos.MoveAroundBall(angle); //target[0] -= 0.3 * cos(Deg2Rad(angle)); //target[1] -= 0.3 * sin(Deg2Rad(angle)); target[0] = pos[0]; target[1] = pos[1]; DoLog(LOG_INTERCEPT,"interception Adjusted. target = (%.2f,%.2f)",target[0],target[1]); } action_info.x = target[0]; action_info.y = target[1]; action_info.do_drive = true; return true;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?