Hec*_*ret 2 iphone math gps measurement coordinates
在iPhone上,我以十进制度获取用户的位置,例如:北纬39.470920和经度= -0.373192; 那是A点.
我需要创建一个具有另一个GPS坐标的线,也是十进制度,B点.然后,计算从A到B的线与另一个点C之间的距离(垂直).
问题是我对度数的值感到困惑.我希望得到米的结果.转换需要什么?计算这个的最终公式怎么样?
oxi*_*gen 10
use - (CLLocationDistance)getDistanceFrom:(const CLLocation*)location
firstLongitude = 30.0;
firstLatitude = 30.0;
secondLongitude = 40.0;
secondLatitude = 40.0;
CLLocation *firstLoc = [[CLLocation alloc]initWithLatitude:firstLatitude longitude: firstLongitude];
CLLocation *secondLoc = [[CLLocation alloc]initWithLatitude:secondLatitude longitude: secondLongitude];
double distanceInMeters = [firstLoc getDistanceFrom: secondLoc];
Run Code Online (Sandbox Code Playgroud)
你的问题并不重要:在一个椭圆体上,甚至可能有多条线垂直于AB到C.
如果距离很小,您可能会使用欧几里德近似值
?x = R·cos?·??
?y = r·??
r = b²/?(b² + (a² - b²)·cos²?)
R·cos? = a²/?(a² + b²·tan²?)
Run Code Online (Sandbox Code Playgroud)
纬度?,经度?,半长轴a和半轴b; 在球面近似中a = b.该?公式中的r和R·cos?必须是某种平均值.
球体上的度量http://img263.imageshack.us/img263/3620/spheroid.gif
可能提供更好结果的方法是在3空间(而不是在球体的表面上)解决问题并获得与连接线相关的弧长.
要做到这一点,您需要知道如何从具有法线角度的地理坐标转换?为笛卡尔坐标
z = b²·sin?/?(a²·cos²? + b²·sin²?)
r = a²·cos?/?(a²·cos²? + b²·sin²?)
x = r·cos?
y = r·sin?
Run Code Online (Sandbox Code Playgroud)
从地心坐标到极角?到笛卡尔坐标
z = a·b·sin?/?(a²·sin²? + b²·cos²?)
r = a·b·cos?/?(a²·sin²? + b²·cos²?)
x = r·cos?
y = r·sin?
Run Code Online (Sandbox Code Playgroud)
请注意,r这些公式中的公式与上图中的公式不同.
让A,B,C在欧几里得空间相对应的球体的表面上的点的载体.垂直的脚F是由
F = 1/|B-A|² · (<B-A,C-A>·B - <B-A,C-B>·A)
Run Code Online (Sandbox Code Playgroud)
<,>标量积和|·|标准在哪里.
现在,我们必须确定F'球体表面上对应的点F,这意味着我们必须计算
?' = atan2(y,x)
?' = arctan(z/?(x² + y²))
Run Code Online (Sandbox Code Playgroud)
然后将它们转换回笛卡尔坐标.
割线的长度由下式给出
d = |F'- C|
Run Code Online (Sandbox Code Playgroud)
球面近似中相应的弧长是
s = R·?
Run Code Online (Sandbox Code Playgroud)
其中?是之间的角度F'和C,即
? = arccos(cos?) = arccos(<F',C>/(|F'|·|C|))
Run Code Online (Sandbox Code Playgroud)
并且R是由给定的平均半径
R = ³?(a²·b)
Run Code Online (Sandbox Code Playgroud)
或使用余弦规则为小距离提供更好的价值
R = d/?(2·(1 - cos?))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5490 次 |
| 最近记录: |