在iOS中测量/计算距离 [英] Measuring/Calculating Distance in iOS

查看:309
本文介绍了在iOS中测量/计算距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计算iOS中两点之间的距离。我可以保证至少一个iPhone 4,所以相机上的图片质量应该是好的。这个想法是使用图片计算到一个点的距离。有一个名为easyMeasure的应用程序,这正是我需要做的。

I need to calculate the distance between two points in iOS. I can guarantee at least an iPhone 4 so the picture quality on the camera should be good. The idea is to calculate the distance to a point using the picture. There's an app called easyMeasure which does exactly what I need to do.

我对毕达哥拉斯确定,但是这让我迷惑。我将如何做这样的事情?

I'm ok with Pythagoras but this boggles my mind. How would I do something like this?

推荐答案

好的,所以你是正确的,你需要使用正弦等。首先,你需要找到iPhones相机的镜头角度。做到这一点,把相机与墙壁已知的距离,并测量从视野的边缘到另一边,并除以二的距离。要在下面的图片中找到θ,请使用tanθ= opposite / adjacent,因此逆tan(相反/相邻)=θ。

Ok, so you were correct in that you need to use sine and such. First though, you'll need to find the lens angle of the iPhones camera. Do do this, put the camera a known distance away from the wall and measure how far it is from the edge of the field of vision to the other side and divide by two. To find θ in the picture below, use tanθ = opposite/adjacent, so inverse tan(opposite/adjacent) = θ.

一旦你知道,你只需让用户拍摄一张照片,对于屏幕上有多大的东西真的是。然后只需使用tanθ= opposite / adjacent,因为你现在知道θ和相反的距离,adjacent = opposite /tanθ。

Once you know that, you just have the user take a picture, and give a measurement for how big something on the screen really is. Then just use tanθ = opposite/adjacent, and since you now know θ and the opposite distance, adjacent = opposite/tanθ.

希望有所帮助!

这篇关于在iOS中测量/计算距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆