获取向量的另一个坐标

1.已知一个点的坐标和点的方位角,角度0-360

2.获取点坐标方位角的方向上的另一个点的坐标(指定距离范围)

其中radians代表方位角

    /**
     * 获取向量的另一个坐标
     * @param latLonReq
     * @param range
     * @return
     */
    public static LatLonReq getDegreesCoordinates(LatLonReq latLonReq, double range){
        double distance = Optional.ofNullable(range).orElse(1000.0);
        double latitude = latLonReq.getLatitude();
        double longitude = latLonReq.getLongitude();
        double radians = latLonReq.getRadians();
        double cosLine = Math.cos(Math.toRadians(radians)) * distance;
        double sinLine = Math.sin(Math.toRadians(radians)) * distance;
        double diffLat = cosLine / oneLatitudeDistance();
        double diffLon = sinLine / oneLongitudeDistance(latitude, longitude);
        double reLat = diffLat + latitude;
        double reLon = diffLon + longitude;
        return new LatLonReq(reLat, reLon);
    }
    /**
     * 1纬度距离
     * @return
     */
    public static double oneLatitudeDistance(){
        return PI * R / 180;
    }
    /**
     * 纬度相同,1经度距离
     * @param latitude
     * @param longitude
     * @return
     */
    public static double oneLongitudeDistance(double latitude, double longitude){
        LatLonReq latLonReq = new LatLonReq(latitude, longitude);
        double longitudeEnd = longitude + 1.0;
        return getDistance(latLonReq, new LatLonReq(latitude, longitudeEnd));
    }

 

posted on 2021-11-25 11:40  我是你爷爷的爷爷  阅读(98)  评论(0编辑  收藏  举报

导航