with Point Radius - Android Graphics

Android examples for Graphics:Path Point

Description

with Point Radius

Demo Code


//package com.java2s;

import android.graphics.PointF;

public class Main {
    public static boolean withPointRadius(int x, int y, PointF target,
            float radius) {
        PointF cur = new PointF(x, y);
        return withPointRadius(cur, target, radius);
    }/*from  ww w . ja va  2 s . co m*/

    public static boolean withPointRadius(float x, float y, PointF target,
            float radius) {
        PointF cur = new PointF(x, y);
        return withPointRadius(cur, target, radius);
    }

    public static boolean withPointRadius(PointF cur, PointF target,
            float radius) {
        double space_2 = Math.pow(Math.abs(cur.x - target.x), 2)
                + Math.pow(Math.abs(cur.y - target.y), 2);
        double space = Math.sqrt(space_2);
        if (radius > space) {
            return true;
        }
        return false;
    }
}

Related Tutorials