get Square Distance Between Points - Android java.lang

Android examples for java.lang:Math Geometry

Description

get Square Distance Between Points

Demo Code


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

public class Main {
    public static float getSquareDistanceBetweenPoints(PointF a, PointF b) {
        return (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
    }/*from w w  w  .  j  a va  2s . c  om*/

    public static float getSquareDistanceBetweenPoints(float ax, float ay,
            float bx, float by) {
        return (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
    }
}

Related Tutorials