Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. double power = 2.0;
  2. double alfa = 180 + (Math.abs(getHeading() + e.getBearing()) % 360) - e.getHeading();
  3. double t = e.getDistance()/(20-(3*power))
  4. double b = t*8;
  5. double c = e.getDistance();
  6. double a = b*b + c*c - 2*b*c*Math.cos(alfa); //cosinusregel
  7. double beta = Math.asin((b*Math.sin(alfa))/a); //sinusregel
  8. double alfa2 = 180 - alfa;
  9. double b2 = (v-t)*t;
  10. double a2 = b2*b2 + c*c - 2*b2*c*Math.cos(alfa2); //cosinusregel
  11. double beta2 = Math.asin((b2*Math.sin(alfa2))/a2); //sinusregel
  12. double richtingTegenstander = (e.getBearing() + getHeading()) % 360;
  13. double ondergrens = getGunHeading() - richtingTegenstander + beta2;
  14. double bovengrens = getGunHeading() - richtingTegenstander - beta;
  15. double turn = (ondergrens+(bovengrens-ondergrens)*r.nextDouble())%360;
  16. if (turn<180) { turnGunLeft(turn); }
  17. else { turnGunRight(360-turn); }
  18. fire(power);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement