iPhone 上的 distanceFromLocation 与自己用笛卡尔坐标计算的距离有多准确?

发布于 2024-10-21 01:44:24 字数 1446 浏览 4 评论 0 原文

在 Iphone SDK 中,distanceFromLocation: 表示它根本不使用海拔高度。如果我正在编写一个应用程序来跟踪我步行/骑自行车/等的距离(是的,我知道已经有很多人这样做了),我很好奇这有多重要。有人有这方面的经验吗?

当我说笛卡尔线时,我的意思是这样的(在 C# 中,而不是 Objective C):

        double lattitude, longitude, altitude, x, y, z, x1, y1, z1, S;
        double a = 6378137, C, f = 1 / 298.257224;

        lattitude = <insert degrees> * Math.PI / 180.0;
        longitude = <insert degrees> * Math.PI / 180.0;
        altitiude = <insert altitude>

        C= 1 / (Math.Sqrt(Math.Pow(Math.Cos(lattitude),2.0) + Math.Pow((1 - f),2.0) *Math.Pow(Math.Sin(lattitude),2.0)));
        S = Math.Pow(1 - f, 2.0) * C;
        x = (a*C+altitude) * Math.Cos(lattitude) * Math.Cos(longitude);
        y = (a*C+altitude) *Math.Cos(lattitude) * Math.Sin(longitude);
        z = (a*S+altitude) * Math.Sin(lattitude);

        lattitude = <insert degrees new> * Math.PI / 180.0;
        longitude = <insert degrees new> * Math.PI / 180.0;
        altitiude = <insert altitude new>;


        x1 = (a * C + altitude) * Math.Cos(lattitude) * Math.Cos(longitude);
        y1 = (a * C + altitude) * Math.Cos(lattitude) * Math.Sin(longitude);
        z1 = (a * S + altitude) * Math.Sin(lattitude);

        double distance;
        distance = Math.Sqrt(Math.Pow(x1 - x, 2.0) + Math.Pow(y1 - y, 2.0) + Math.Pow(z1 - z, 2.0));

有人知道它实际上有多大的区别吗?本质上它是如何在iphone上精确计算的?大圆距离?我似乎无法在任何地方找到答案

In the Iphone SDK the distanceFromLocation: says it doesn't use altitude at all. If I'm writing an app to track how far I walk/cycle/ect (yes I know there are a number that do this already), I'm curious how much that matters. Does anyone have experience with this?

When I say cartesian cords I mean something like this (in C#, not objective C):

        double lattitude, longitude, altitude, x, y, z, x1, y1, z1, S;
        double a = 6378137, C, f = 1 / 298.257224;

        lattitude = <insert degrees> * Math.PI / 180.0;
        longitude = <insert degrees> * Math.PI / 180.0;
        altitiude = <insert altitude>

        C= 1 / (Math.Sqrt(Math.Pow(Math.Cos(lattitude),2.0) + Math.Pow((1 - f),2.0) *Math.Pow(Math.Sin(lattitude),2.0)));
        S = Math.Pow(1 - f, 2.0) * C;
        x = (a*C+altitude) * Math.Cos(lattitude) * Math.Cos(longitude);
        y = (a*C+altitude) *Math.Cos(lattitude) * Math.Sin(longitude);
        z = (a*S+altitude) * Math.Sin(lattitude);

        lattitude = <insert degrees new> * Math.PI / 180.0;
        longitude = <insert degrees new> * Math.PI / 180.0;
        altitiude = <insert altitude new>;


        x1 = (a * C + altitude) * Math.Cos(lattitude) * Math.Cos(longitude);
        y1 = (a * C + altitude) * Math.Cos(lattitude) * Math.Sin(longitude);
        z1 = (a * S + altitude) * Math.Sin(lattitude);

        double distance;
        distance = Math.Sqrt(Math.Pow(x1 - x, 2.0) + Math.Pow(y1 - y, 2.0) + Math.Pow(z1 - z, 2.0));

Does anyone know how much of a difference it actually makes? Essentially how it is calculated precisely on iphone? Great circle distance? I can't seem to find the answer anywhere

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

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

发布评论

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

评论(1

笑,眼淚并存 2024-10-28 01:44:24

文档说:

“该方法测量距离
通过追踪两个位置之间的
它们之间的线遵循
地球的曲率。由此产生的
arc 是一条平滑曲线,并且不
考虑到特定的海拔高度
两个位置之间的变化。”

对我来说,这意味着大圆距离(事实上,它几乎是 "

我的理解(虽然我肯定不是专家)是大圆计算(例如 Haversine)非常典型,并且通常被认为对于大多数应用程序来说“足够好”。

有关该主题的信息可能比您想要的多得多 此处这个问题也是半相关的。

如果你真的关心它,我会尝试几种不同的算法,看看你是否可以确定哪个最适合你的需求。

The docs say:

"This method measures the distance
between the two locations by tracing a
line between them that follows the
curvature of the Earth. The resulting
arc is a smooth curve and does not
take into account specific altitude
changes between the two locations."

To me, that implies Great Circle distance (in fact, it's nearly the definition of it).

My understanding (though I'm certainly no expert) is that great circle calculations (such as Haversine) are very typical, and generally considered "good enough" for most applications.

There's probably way more information than you want on the topic here. This question is semi-related as well.

If you're really concerned about it, I'd try a few different algorithms, and see if you can determine which best suits your needs.

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