已知起点和距离计算第二点

发布于 2024-08-20 13:09:31 字数 317 浏览 6 评论 0原文

使用纬度和经度值(A 点),我尝试计算另一个点 B,距离 A 点 X 米,距离 A 点 0 弧度。然后显示 B 点的纬度和经度值。

示例(伪代码):

PointA_Lat = x.xxxx;
PointA_Lng = x.xxxx;
Distance = 3; //Meters
bearing = 0; //radians

new_PointB = PointA-Distance;

我能够计算两点之间的距离,但我想找到的是知道距离和方位的第二个点。

最好是 PHP 或 Javascript。

谢谢

using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values.

Example (Pseudo code):

PointA_Lat = x.xxxx;
PointA_Lng = x.xxxx;
Distance = 3; //Meters
bearing = 0; //radians

new_PointB = PointA-Distance;

I was able to calculate the distance between two Points but what I want to find is the second point knowing the distance and bearing.

Preferably in PHP or Javascript.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

拧巴小姐 2024-08-27 13:09:31

您似乎正在以米为单位测量距离 (R),并从正东逆时针方向测量 (theta)。对于您的目的(数百米),平面几何应该足够准确。在这种情况下,

dx = R*cos(theta) ; theta measured counterclockwise from due east
dy = R*sin(theta) ; dx, dy same units as R

如果 theta 是从正北顺时针测量的(例如,罗盘方位角),
dx 和 dy 的计算略有不同:

dx = R*sin(theta)  ; theta measured clockwise from due north
dy = R*cos(theta)  ; dx, dy same units as R

无论哪种情况,经度和纬度的变化为:

delta_longitude = dx/(111320*cos(latitude))  ; dx, dy in meters
delta_latitude = dy/110540                   ; result in degrees long/lat

常数 110540 和 111320 之间的差异是由于地球的扁率造成的
(极地周长和赤道周长不同)。

这是一个有效的示例,使用您后面的问题中的参数:

给定起始位置为经度 -87.62788 度,纬度 41.88592 度,
找到距起始位置西北 500 米的点的坐标。

如果我们从正东逆时针测量角度,“西北”对应
到 theta=135 度。 R为500米。

dx = R*cos(theta) 
   = 500 * cos(135 deg) 
   = -353.55 meters

dy = R*sin(theta) 
   = 500 * sin(135 deg) 
   = +353.55 meters

delta_longitude = dx/(111320*cos(latitude)) 
                = -353.55/(111320*cos(41.88592 deg))
                = -.004266 deg (approx -15.36 arcsec)

delta_latitude = dy/110540
               = 353.55/110540
               =  .003198 deg (approx 11.51 arcsec)

Final longitude = start_longitude + delta_longitude
                = -87.62788 - .004266
                = -87.632146

Final latitude = start_latitude + delta_latitude
               = 41.88592 + .003198
               = 41.889118

It seems you are measuring distance (R) in meters, and bearing (theta) counterclockwise from due east. And for your purposes (hundereds of meters), plane geometry should be accurate enough. In that case,

dx = R*cos(theta) ; theta measured counterclockwise from due east
dy = R*sin(theta) ; dx, dy same units as R

If theta is measured clockwise from due north (for example, compass bearings),
the calculation for dx and dy is slightly different:

dx = R*sin(theta)  ; theta measured clockwise from due north
dy = R*cos(theta)  ; dx, dy same units as R

In either case, the change in degrees longitude and latitude is:

delta_longitude = dx/(111320*cos(latitude))  ; dx, dy in meters
delta_latitude = dy/110540                   ; result in degrees long/lat

The difference between the constants 110540 and 111320 is due to the earth's oblateness
(polar and equatorial circumferences are different).

Here's a worked example, using the parameters from a later question of yours:

Given a start location at longitude -87.62788 degrees, latitude 41.88592 degrees,
find the coordinates of the point 500 meters northwest from the start location.

If we're measuring angles counterclockwise from due east, "northwest" corresponds
to theta=135 degrees. R is 500 meters.

dx = R*cos(theta) 
   = 500 * cos(135 deg) 
   = -353.55 meters

dy = R*sin(theta) 
   = 500 * sin(135 deg) 
   = +353.55 meters

delta_longitude = dx/(111320*cos(latitude)) 
                = -353.55/(111320*cos(41.88592 deg))
                = -.004266 deg (approx -15.36 arcsec)

delta_latitude = dy/110540
               = 353.55/110540
               =  .003198 deg (approx 11.51 arcsec)

Final longitude = start_longitude + delta_longitude
                = -87.62788 - .004266
                = -87.632146

Final latitude = start_latitude + delta_latitude
               = 41.88592 + .003198
               = 41.889118
想挽留 2024-08-27 13:09:31

如果您知道 3600 弧秒为 1 度(纬度或经度)、一海里有 1852 米、一海里为 1 弧秒,这可能会有所帮助。当然,您所依赖的距离相对较短,否则您将不得不使用球面三角学。

It might help if you knew that 3600 seconds of arc is 1 degree (lat. or long.), that there are 1852 meters in a nautical mile, and a nautical mile is 1 second of arc. Of course you're depending on the distances being relatively short, otherwise you'd have to use spherical trigonometry.

不弃不离 2024-08-27 13:09:31

这是使用 Swift 的更新版本:

let location = CLLocation(latitude: 41.88592 as CLLocationDegrees, longitude: -87.62788 as CLLocationDegrees)

let distanceInMeter : Int = 500
let directionInDegrees : Int = 135

let lat = location.coordinate.latitude
let long = location.coordinate.longitude

let radDirection : CGFloat = Double(directionInDegrees).degreesToRadians

let dx = Double(distanceInMeter) * cos(Double(radDirection)) 
let dy = Double(distanceInMeter) * sin(Double(radDirection))

let radLat : CGFloat = Double(lat).degreesToRadians

let deltaLongitude = dx/(111320 * Double(cos(radLat)))  
let deltaLatitude = dy/110540                   

let endLat = lat + deltaLatitude
let endLong = long + deltaLongitude

使用此扩展:

extension Double {
    var degreesToRadians : CGFloat {
        return CGFloat(self) * CGFloat(M_PI) / 180.0
    }
}

Here is an updated version using Swift:

let location = CLLocation(latitude: 41.88592 as CLLocationDegrees, longitude: -87.62788 as CLLocationDegrees)

let distanceInMeter : Int = 500
let directionInDegrees : Int = 135

let lat = location.coordinate.latitude
let long = location.coordinate.longitude

let radDirection : CGFloat = Double(directionInDegrees).degreesToRadians

let dx = Double(distanceInMeter) * cos(Double(radDirection)) 
let dy = Double(distanceInMeter) * sin(Double(radDirection))

let radLat : CGFloat = Double(lat).degreesToRadians

let deltaLongitude = dx/(111320 * Double(cos(radLat)))  
let deltaLatitude = dy/110540                   

let endLat = lat + deltaLatitude
let endLong = long + deltaLongitude

Using this extension:

extension Double {
    var degreesToRadians : CGFloat {
        return CGFloat(self) * CGFloat(M_PI) / 180.0
    }
}
暗喜 2024-08-27 13:09:31

dx = sin(方位角)
dy = cos(轴承)
x = center.x + distdx;
y = center.y + dist
dy;

dx = sin(bearing)
dy = cos(bearing)
x = center.x + distdx;
y = center.y + dist
dy;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文