Calculate angle for two Points - Android java.lang

Android examples for java.lang:Math Geometry

Description

Calculate angle for two Points

Demo Code


//package com.java2s;
import android.graphics.PointF;

public class Main {
    public static float angle(PointF p1, PointF p2) {
        return angle(p1.x, p1.y, p2.x, p2.y);
    }/*from  ww w.j a  v  a2 s.  co m*/

    private static float angle(float x1, float y1, float x2, float y2) {
        return (float) Math.atan2(y2 - y1, x2 - x1);
    }
}

Related Tutorials