有问题发邮件 310880288@qq.com
public static boolean isInRectangle(Vector2D pointA, Vector2D pointB, Vector2D point)
{
List<Vector2D> polygon = new ArrayList<Vector2D>();
polygon.add(pointA);
polygon.add(new Vector2D(pointA.getX(), pointB.getY()));
polygon.add(pointB);
polygon.add(new Vector2D(pointB.getX(), pointA.getY()));
return CalcPointPolygonRelation(point, polygon);
}
private static double Distance(double lon1, double lat1, double lon2, double lat2)
{
double R = 6378137; //地球半径
lat1 = lat1 * Math.PI / 180.0;
lat2 = lat2 * Math.PI / 180.0;
double sa2 = Math.sin((lat1 - lat2) / 2.0);
double sb2 = Math.sin(((lon1 - lon2) * Math.PI / 180.0) / 2.0);
return 2 * R * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2));
}
// cPoint 圆心坐标
// cRadius 圆半径
// point 当前点
public static boolean isInCircle(Vector2D cPoint, double cRadius, Vector2D point)
{
double distance = Distance(cPoint.getX(), cPoint.getY(), point.getX(), point.getY());
return distance <= cRadius;