Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double alfa = 180 + (Math.abs(getHeading() + e.getBearing()) % 360) - e.getHeading();
- double t = e.getDistance()/(20-(3*power));
- double b = t*8;
- double c = e.getDistance();
- double a = b*b + c*c - 2*b*c*Math.cos(alfa); //cosinusregel
- double beta = Math.asin((b*Math.sin(alfa))/a); //sinusregel
- double b2 = (e.getVelocity() -t)*t;
- double alfa2;
- if(b2 > 0) {
- alfa2 = alfa;
- }
- else {
- alfa2 = 180 - alfa;
- b2 = -b2;
- }
- double a2 = b2*b2 + c*c - 2*b2*c*Math.cos(alfa2); //cosinusregel
- double beta2 = Math.asin((b2*Math.sin(alfa2))/a2); //sinusregel
- double richtingTegenstander = (e.getBearing() + getHeading()) % 360;
- double ondergrens = getGunHeading() - richtingTegenstander + beta2;
- double bovengrens = getGunHeading() - richtingTegenstander - beta;
- double turn = (ondergrens+(bovengrens-ondergrens)*r.nextDouble())%360;
- if (turn<180) { setTurnGunLeft(turn); }
- else { setTurnGunRight(360-turn); }
- setFire(power);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement