墨卡托地图投影逻辑冲突
我正在寻找解释为什么这些网站上讨论了两种不同的墨卡托公式。
我理解这是正确的墨卡托投影算法:
http://en.wikipedia.org/wiki/Mercator_projection< /a>
y = ln|sec(lat) + tan(lat)|
然而,这个网站指的是完全不同的东西: http://wiki.openstreetmap.org/wiki/Mercator
#include <math.h>
double lat2y(double a) { return 180/M_PI * log(tan(M_PI/4+a*(M_PI/180)/2)); }
有什么想法吗?
I'm looking for an explanation on why there are 2 different mercator formulas discussed on these sites.
I understand this to be the correct mercator projection algorithm:
http://en.wikipedia.org/wiki/Mercator_projection
y = ln|sec(lat) + tan(lat)|
However, this site refers to something completely different:
http://wiki.openstreetmap.org/wiki/Mercator
#include <math.h>
double lat2y(double a) { return 180/M_PI * log(tan(M_PI/4+a*(M_PI/180)/2)); }
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个公式是相等的。
sec(x) + tan(x) = [ 1 + sin(x) ] / cos(x)
tan(pi/4 + x/2) = sin(pi/4 + x/2) / cos(pi/4 + x/2) =
= [cos(x/2) + sin(x/2)] / [cos(x/2) - sin(x/2)] =
= [cos(x/2) + sin(x/2)]^2 / [cos(x/2) - sin(x/2)] / [cos(x/2) + sin(x/ 2)] =
= [1 + 2*cos(x/2)*sin(x/2)] / [cos^2(x/2) - sin^2(x/2)] =
= [1 + sin(x)] / cos(x)
后一个公式更便于数值计算,因为它只涉及三角函数的计算 一次。
Both formulas are equal.
The latter formula is more convenient for numerical calculations, because it involves the computation of the trigonometric function only once.