Calculate distance between two PointF - Android android.location

Android examples for android.location:Distance

Description

Calculate distance between two PointF

Demo Code

import android.graphics.PointF;

public class Main{

    public static float dist(PointF p1, PointF p2) {
        float dist = (float) Math.sqrt(Math.pow(p2.x - p1.x, 2)
                + Math.pow(p2.y - p1.y, 2));
        return dist;
    }//ww w.  j  a  v  a2s .  com

}

Related Tutorials