Guest User

Untitled

a guest
Jan 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package kf2ads;
  2.  
  3. import java.math.RoundingMode;
  4. import java.text.DecimalFormat;
  5.  
  6. public class Normalization {
  7. double rfov, coef;
  8. double[] zoom, rzoom;
  9. String[] bind;
  10.  
  11. public Normalization(double f, double c) {
  12. rfov = Math.toRadians(90 * f);
  13. coef = c;
  14. zoom = new double[6];
  15. zoom[0] = 80 * f;
  16. zoom[1] = 77 * f;
  17. zoom[2] = 75 * f;
  18. zoom[3] = 73 * f;
  19. zoom[4] = 70 * f;
  20. zoom[5] = 65 * f;
  21. rzoom = new double[6];
  22. for (int i = 0; i < rzoom.length; i++) {
  23. rzoom[i] = Math.toRadians(zoom[i]);
  24. }
  25. bind = new String[6];
  26. calcBind();
  27. }
  28.  
  29. public void calcBind() {
  30. DecimalFormat df = new DecimalFormat("#.######");
  31. df.setRoundingMode(RoundingMode.HALF_UP);
  32. bind[0] = "SetBind NumpadOne \"fov " + df.format(zoom[0]) + "|SetZoomedSensitivity " + df.format(Normalize(0))
  33. + "\"";
  34. bind[1] = "SetBind NumpadTwo \"fov " + df.format(zoom[1]) + "|SetZoomedSensitivity " + df.format(Normalize(1))
  35. + "\"";
  36. bind[2] = "SetBind NumpadThree \"fov " + df.format(zoom[2]) + "|SetZoomedSensitivity " + df.format(Normalize(2))
  37. + "\"";
  38. bind[3] = "SetBind NumpadFour \"fov " + df.format(zoom[3]) + "|SetZoomedSensitivity " + df.format(Normalize(3))
  39. + "\"";
  40. bind[4] = "SetBind NumpadFive \"fov " + df.format(zoom[4]) + "|SetZoomedSensitivity " + df.format(Normalize(4))
  41. + "\"";
  42. bind[5] = "SetBind NumpadSix \"fov " + df.format(zoom[5]) + "|SetZoomedSensitivity " + df.format(Normalize(5))
  43. + "\"";
  44. }
  45.  
  46. public double Normalize(int z) {
  47. if (coef > 0)
  48. return Math.atan(coef * Math.tan(rzoom[z] / 2)) / Math.atan(coef * Math.tan(rfov / 2)) / zoom[z] / 0.013330;
  49. return Math.tan(rzoom[z] / 2) / Math.tan(rfov / 2) / zoom[z] / 0.013330;
  50. }
  51.  
  52. public String toString() {
  53. String output = "";
  54. for (String s : bind)
  55. output += s + "|";
  56. return output.substring(0, output.length() - 1);
  57. }
  58. }
Add Comment
Please, Sign In to add comment