嘿,我想计算1点的距离,另一对iPhone(水平)林不知道发现从A点到B点的距离为iPhone
0
A
回答
0
怎么嗨,你需要创建的实例CLLocation,并调用计算的方法。
CLLocation *locationOne = [[CLLocation alloc] initWithLatitude:[point coordinate].latitude longitude:[point coordinate].longitude];
CLLocation *locationTwo = [[CLLocation alloc] initWithLatitude:[secondPoint coordinate].latitude longitude:[secondPoint coordinate].longitude];
double distanceInMeters = [locationOne distanceFromLocation:locationTwo];
如果你想要两个点之间的距离,你应该记住Pitagora:
CGPoint pointA, pointB;
double distancesInPoints = sqrt((pointA.x-pointB.x)*(pointA.x-pointB.x) + (pointA.y-pointB.y)*(pointA.y-pointB.y));
+0
当然,你需要Core Location框架给你项目和ViewController。 – 2014-11-08 18:18:05
+1
你假设地理位置被要求,更可能只是CGPoint距离 – LearnCocos2D 2014-11-08 18:37:25
相关问题
- 1. A,B之间的距离
- 2. Elasticsearch:基于距离的订单项目到A点,但显示的距离B点计算
- 3. 将UILabel从A点拖到B点
- 4. 直接从A点移动到B点
- 5. 从点到另一点的距离
- 6. 使用jQuery将点表A从点A移动到点B
- 7. 如何从两个点计算距离,点A是用户的位置,B点为Placepicker.getlatlang()
- 8. 从点+半径/距离(iPhone SDK)的MKPolygon
- 9. Excel工作表到iPhone数据 - A点到B点
- 10. 给定两个点集A和B,你如何找到离B最远的点?
- 11. 谷歌地图jQuery使用字符串城市/县名称绘制从点A到点B的距离
- 12. 找到距离地点最小总距离的点的算法
- 13. 移动gameObject点A到点B
- 14. GIS,OSM,ROUTING:如何通过'road'节点从A点到B点?
- 15. 到点的最短距离
- 16. 从二维空间中的点A到点B的标题?
- 17. (iphone)怪异EXC_BAD_ACCESS,在A :: A()中回溯但代码点到B :: B()
- 18. 查找从A点到B点的路径(n个循环)
- 19. 单点的距离
- 20. 如何在GLSL中实现从点到线段的距离?
- 21. 如何从A点到B点如导航系统
- 22. 将对象从A点移动到B点
- 23. 以恒定速度将物体从点A移动到点B
- 24. Libgdx Actions =>将演员从A点逐渐移动到B点
- 25. 从{a-b,b-c,c-a}改变为{(a,b),(b,c),(c,a)}?
- 26. 从地图上的一点到另一点之间的距离
- 27. 距离某一点的线段距离上的点
- 28. 更新中从起点到终点的距离
- 29. FFmpeg的 - 从A点移动覆盖到B到C到d
- 30. 根据距离原点的距离排序2d点
开放CGPointExtension.h在cocos2d的项目,你会发现ccpDistance和其他 – LearnCocos2D 2014-11-08 18:37:43