@AdityaMangalamp/

DistanceFormulaW/Angle

Java

No description

fork
loading
Files
  • Main.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.018126861236684055","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"Y2xhc3MgTWFpbiB7CiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgCiAgICBEaXN0YW5jZUZvcm11bGEoMywgMi41LCAtMSwgMi41KTsKICB9CiAgcHJpdmF0ZSBzdGF0aWMgdm9pZCBEaXN0YW5jZUZvcm11bGEoZG91YmxlIHgxLCBkb3VibGUgeTEsIGRvdWJsZSB4MiwgZG91YmxlIHkyKSB7CiAgICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAgICAgIC8vQ2FsY3VsYXRpbmcgRGlzdGFuY2UgZnJvbSBwb2ludHMgQSA9ICh4MiwgeTIpICYgQiA9ICh4MiwgeTIpICYgQyA9ICh4MywgeTMpCiAgICAgIC8vVXNlZCBkaXN0YW5jZSBmb3JtdWxhCiAgICAgIGRvdWJsZSBsZW5ndGhfYWIgPSBNYXRoLnNxcnQoTWF0aC5wb3coKHgyIC0geDEpLCAyKSArIE1hdGgucG93KCh5MiAtIHkxKSwgMikpOwogICAgICBkb3VibGUgZGlzdGFuY2UgPSBsZW5ndGhfYWIqMjQ7CiAgICAgIGRvdWJsZSBsZW5ndGhfYmMgPSBNYXRoLnNxcnQoTWF0aC5wb3coKHgyIC0geDIpLCAyKSArIE1hdGgucG93KCh5MiAtIHkxKSwgMikpOwogICAgICAvLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICAgICAgZG91YmxlIGFuZ2xlX2IgPSBNYXRoLnJpbnQoTWF0aC50b0RlZ3JlZXMoTWF0aC5hY29zKGxlbmd0aF9iYy9sZW5ndGhfYWIpKSk7IC8vYWRqL2h5cAogICAgICAvLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogICAgICBkb3VibGUgdHVybl9hbmdsZSA9IDAuMDAwOwogICAgICBpZiAoeDEgPD0geDIpIHsKICAgICAgICBpZiAoeTEgPD0geTIpIHsKICAgICAgICAgIHR1cm5fYW5nbGUgPSAtKGFuZ2xlX2IpOwogICAgICAgIH0KCiAgICAgICAgZWxzZSBpZiAoeTEgPiB5MikgewogICAgICAgICAgdHVybl9hbmdsZSA9IC0oMTgwLWFuZ2xlX2IpOwogICAgICAgIH0KICAgICAgICAgCiAgICAgIH0KCiAgICAgIGVsc2UgaWYgKHgxID4geDIpIHsKICAgICAgICBpZiAoeTEgPD0geTIpIHsKICAgICAgICAgIHR1cm5fYW5nbGUgPSAtYW5nbGVfYjsKICAgICAgICB9CgogICAgICAgIGVsc2UgaWYgKHkxID4geTIpIHsKICAgICAgICAgIHR1cm5fYW5nbGUgPSAtKGFuZ2xlX2IgLTE4MCk7CiAgICAgICAgfQogICAgICB9CiAgICAgIC8vUHJpbnRpbmcgYWxsIHN0YXRlbWVudHMKICAgICAgU3lzdGVtLm91dC5wcmludGxuKGRpc3RhbmNlKTsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKHR1cm5fYW5nbGUpOwogIH0KCn0KCiAgCg=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Main {
  public static void main(String[] args) {
    
    DistanceFormula(3, 2.5, -1, 2.5);
  }
  private static void DistanceFormula(double x1, double y1, double x2, double y2) {
     //*******************************************************
      //Calculating Distance from points A = (x2, y2) & B = (x2, y2) & C = (x3, y3)
      //Used distance formula
      double length_ab = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
      double distance = length_ab*24;
      double length_bc = Math.sqrt(Math.pow((x2 - x2), 2) + Math.pow((y2 - y1), 2));
      //*******************************************************
      double angle_b = Math.rint(Math.toDegrees(Math.acos(length_bc/length_ab))); //adj/hyp
      //*********************************************************
      double turn_angle = 0.000;
      if (x1 <= x2) {
        if (y1 <= y2) {
          turn_angle = -(angle_b);
        }

        else if (y1 > y2) {
          turn_angle = -(180-angle_b);
        }
         
      }

      else if (x1 > x2) {
        if (y1 <= y2) {
          turn_angle = -angle_b;
        }

        else if (y1 > y2) {
          turn_angle = -(angle_b -180);
        }
      }
      //Printing all statements
      System.out.println(distance);
      System.out.println(turn_angle);
  }

}