get Angle - Java java.lang

Java examples for java.lang:Math Matrix

Description

get Angle

Demo Code



public class Main{
    public static double getAngle(Point p1, Point p2) {
        int x = p1.getX() - p2.getX();
        int y = p1.getY() - p2.getY();

        double angleToTarget = Math.atan2(x, y);

        return angleToTarget;
    }//  w w  w  .j  av a 2  s  .  c  om
}

Related Tutorials