Android  坐标点是否在简单多边形内

简单多边形是不相邻的边不相交的多边形。判定点p是否在多边形G内部,包括边界。方法很多,这里只讨论android 并尽量使用api方法。
使用方法:通过多边形 path 转Region ,使用Region的contains方法判断。

 private boolean inside(Path path,Point point){
        RectF bounds = new RectF();
        path.computeBounds(bounds, true);
        Region region = new Region();
        region.setPath(path, new Region((int)bounds.left, (int)bounds.top,(int)bounds.right, (int)bounds.bottom));
       if (region.contains(point.x, point.y)){
            return true;
        }
        return false;
    }