2024年3月15日發(作者:祝福媽媽生日快樂的祝福語)

足球機器人程序代碼
//應用程序模板
#include
//判斷自身與球的方位是否危險
bool AzimuthDanger()
{
double ballX = getBallX();
double myX = getX();
double radius = getBallRadius()+getRadius();
if(getAttack()>0 && myX+radius*2>ballX) return true;
if(getAttack()<0 && myX-radius*2 if( (getAttack()>0 && getBallX() (getAttack()<0 && getBallX()>getCourtWidth()/2) ) { if((getBallY()>getCourtHeight()/2)&&(getY()>getBallY() ))return true; if((getBallY() ))return true; } return fal; } //判斷球的運動方向 返回true 危險 bool JudgeDanger() { double ballX = getBallX(); double ballY = getBallY(); double goalMin = getCourtHeight()/2-getGoalWidth()/2; double goalMax = getCourtHeight()/2+getGoalWidth()/2; double b = ballY - tan(getBallHeading())*ballX; if(getAttack()>0 && getBallHeading()>PI/2 && getBallHeading() { if(goalMin<50*tan(getBallHeading()) + b && goalMax>50*tan(getBallHeading()) + b)return true; el return fal; } el if(getAttack()<=0 && (getBallHeading()>=0 && getBallHeading() || getBallHeading()<2*PI && getBallHeading()>3*PI/2)) { if(goalMin && tan(getBallHeading())*(getCourtWidth() - 50) + b return true; el return fal; } el return fal; } //預測足球在times個單位時間后的位置 void Next(int times, double* nextX, double* nextY) { double velocity = getBallVelocity(); double heading = getBallHeading(); double acc = -getBallNegativeAcceleration(); *nextX = getBallX(); *nextY = getBallY(); for (int i = 0; i < times; i++) { if(velocity==0) break; nextPoint(*nextX, *nextY, heading, velocity, nextX, nextY); } } // 摩擦減速 if (velocity > 0) velocity = fmax(0, velocity+acc); el if (velocity < 0) velocity = fmin(0, velocity -acc); // 撞墻檢測 if ((*nextX) < 0 || (*nextX) > getCourtWidth()) { heading = PI - heading; modifyInCourt(nextX, nextY, getBallRadius()); } if ((*nextY) < 0 || (*nextY) > getCourtHeight()) { heading = -heading; modifyInCourt(nextX, nextY, getBallRadius()); } // 跌代計算球的運行線路,計算未來的擊球點 void OptimumPosition(double* hitedX ,double* hitedY ) { *hitedX = getBallX(); 
本文發布于:2024-03-15 07:41:39,感謝您對本站的認可!
本文鏈接:http://m.newhan.cn/zhishi/a/1710459700286400.html
版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。
本文word下載地址:機器人足球代碼1匯編.doc
本文 PDF 下載地址:機器人足球代碼1匯編.pdf
| 留言與評論(共有 0 條評論) |