Formula to calculate distance - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate distance

Demo Code


//package com.java2s;

public class Main {
    private static double result;

    public static double distance(double x1, double x2, double y1, double y2) {
        result = (Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
        return result;
    }//ww  w  .j a v  a2  s  .  c  om
}

Related Tutorials