Calculate distance between two points - Android android.location

Android examples for android.location:Distance

Description

Calculate distance between two points

Demo Code


public class Main{


    public static float distance(float x, float y, float sx, float sy) {
        float dx = x - sx;
        float dy = y - sy;
        return (float) Math.sqrt(dx * dx + dy * dy);
    }/*from  ww  w .j av  a  2 s  . co m*/

}

Related Tutorials