Advertisement
Guest User

Untitled

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