【问题标题】:Having a GPS location and my GPS location, ¿how to calculate the direction (0-360º from north) to the location from my location?拥有 GPS 位置和我的 GPS 位置,¿如何计算从我的位置到该位置的方向(从北方 0-360º)?
【发布时间】:2011-09-27 11:41:25
【问题描述】:

我尝试使用 BearingTo(),但我不知道如何使用它。如果我面向建筑物和北方向,myLocation.bearingTo(BuildingLocation) 给我 0º,如果我面向建筑物和东方向,给我 90º,如果我面向建筑物和南方向,给我 -180º。那么bearingTo 不能满足我的需要。

我需要这样做,因为我需要计算手机摄像头何时面向对象...

【问题讨论】:

    标签: android gps compass-geolocation


    【解决方案1】:

    试试这个链接: http://www.movable-type.co.uk/scripts/latlong.html

    编辑--这将是示例,使用位置或以其他方式获取长/纬度

        Location destination;
        Location from;
    
        double dLon = Math.abs(destination.getLongitude()-from.getLongitude()); //Delta Longitude
    
        double y = Math.sin(dLon) * Math.cos(destination.getLatitude());
        double x = Math.cos(from.getLatitude())*Math.sin(destination.getLatitude()) -
                Math.sin(from.getLatitude())*Math.cos(destination.getLatitude())*Math.cos(dLon);
        double brng = Math.atan2(y, x);
        double brngdegrees = Math.toDegrees(brng);
    

    【讨论】:

    • 不错的链接,但我不明白该怎么做,解释对我来说太复杂了。我不明白如何做我需要的事情:S。有人可以帮我做吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 2018-11-18
    • 2011-03-23
    • 2015-02-17
    相关资源
    最近更新 更多