Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package kf2ads;
- import java.math.RoundingMode;
- import java.text.DecimalFormat;
- public class Normalization {
- double rfov, coef;
- double[] zoom, rzoom;
- String[] bind;
- public Normalization(double f, double c) {
- rfov = Math.toRadians(90 * f);
- coef = c;
- zoom = new double[6];
- zoom[0] = 80 * f;
- zoom[1] = 77 * f;
- zoom[2] = 75 * f;
- zoom[3] = 73 * f;
- zoom[4] = 70 * f;
- zoom[5] = 65 * f;
- rzoom = new double[6];
- for (int i = 0; i < rzoom.length; i++) {
- rzoom[i] = Math.toRadians(zoom[i]);
- }
- bind = new String[6];
- calcBind();
- }
- public void calcBind() {
- DecimalFormat df = new DecimalFormat("#.######");
- df.setRoundingMode(RoundingMode.HALF_UP);
- bind[0] = "SetBind NumpadOne \"fov " + df.format(zoom[0]) + "|SetZoomedSensitivity " + df.format(Normalize(0))
- + "\"";
- bind[1] = "SetBind NumpadTwo \"fov " + df.format(zoom[1]) + "|SetZoomedSensitivity " + df.format(Normalize(1))
- + "\"";
- bind[2] = "SetBind NumpadThree \"fov " + df.format(zoom[2]) + "|SetZoomedSensitivity " + df.format(Normalize(2))
- + "\"";
- bind[3] = "SetBind NumpadFour \"fov " + df.format(zoom[3]) + "|SetZoomedSensitivity " + df.format(Normalize(3))
- + "\"";
- bind[4] = "SetBind NumpadFive \"fov " + df.format(zoom[4]) + "|SetZoomedSensitivity " + df.format(Normalize(4))
- + "\"";
- bind[5] = "SetBind NumpadSix \"fov " + df.format(zoom[5]) + "|SetZoomedSensitivity " + df.format(Normalize(5))
- + "\"";
- }
- public double Normalize(int z) {
- if (coef > 0)
- return Math.atan(coef * Math.tan(rzoom[z] / 2)) / Math.atan(coef * Math.tan(rfov / 2)) / zoom[z] / 0.013330;
- return Math.tan(rzoom[z] / 2) / Math.tan(rfov / 2) / zoom[z] / 0.013330;
- }
- public String toString() {
- String output = "";
- for (String s : bind)
- output += s + "|";
- return output.substring(0, output.length() - 1);
- }
- }
Add Comment
Please, Sign In to add comment