使用纬度和经度值(点A),我正在尝试计算另一个点B,距离A点X轴,距离为0,然后显示B点纬度和经度值。
示例(伪代码):
PointA_Lat = x.xxxx;
PointA_Lng = x.xxxx;
Distance = 3; //Meters
bearing = 0; //radians
new_PointB = PointA-Distance;
我能够计算出两点之间的距离,但我想知道的是知道距离和方位的第二点。
最好是PHP或Javascript。
谢谢
答案 0 :(得分:45)
您似乎正在以米为单位测量距离(R),并从正东方向逆时针方向测量轴承(θ)。为了您的目的(数米的数量),平面几何应该足够准确。在那种情况下,
dx = R*cos(theta) ; theta measured counterclockwise from due east
dy = R*sin(theta) ; dx, dy same units as R
如果从正北方向顺时针测量θ(例如罗盘轴承), 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米处的坐标。
如果我们从正东方向逆时针测量角度,“西北”对应 到θ= 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
答案 1 :(得分:3)
如果你知道3600秒的弧度是1度(纬度或长度),那么在海里有1852米,海里是1秒的弧度,这可能会有所帮助。当然,你取决于相对较短的距离,否则你必须使用球面三角法。
答案 2 :(得分:2)
这是使用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
}
}
答案 3 :(得分:-1)
dx = sin(方位)
dy = cos(方位)
x = center.x + dist dx;
y = center.y + dist dy;