计算2点之间的距离
来源:互联网 发布:python哪些教程比较好 编辑:程序博客网 时间:2024/05/19 20:19
计算2点之间的距离:
#import "Point2D.h"#import <math.h>@interface Point2D (){ double _x; double _y;}//set和get方法-(void)setX:(double)x;-(double)x;-(void)setY:(double)y;-(double)y;-(void)setX:(double)x andsetY:(double)y;//计算距离方法-(double)distanceWithOtherPoint:(Point2D *)point;+(double)distanceWithPoint1:(Point2D *)point1 andPoint2:(Point2D *)point2;@end@implementation Point2D//x-(void)setX:(double)x{ _x = x;}-(double)x{ return _x;}//y-(void)setY:(double)y{ _y = y;}-(double)y{ return _y;}-(void)setX:(double)x andsetY:(double)y{ [self setX:x]; [self setY:y];}-(double)distanceWithOtherPoint:(Point2D *)point{ //X^2 double xDelta = [self x]-[point x]; double xDeltaPF = pow(xDelta, 2); //Y^2 double yDelta = [self y]-[point y]; double yDeltaPF = pow(yDelta, 2); return sqrt(xDeltaPF+yDeltaPF);//开根号}+(double)distanceWithPoint1:(Point2D *)point1 andPoint2:(Point2D *)point2{ return [point2 distanceWithOtherPoint:point1];}int main(int argc, const char * argv[]) { Point2D * p1 = [Point2D new]; Point2D * p2 = [Point2D new]; [p1 setX:10 andsetY:90]; [p2 setX:80 andsetY:67]; double distance = [Point2D distanceWithPoint1:p1 andPoint2:p2]; NSLog(@"distance=%f",distance); return 0;}@end
0 0
- 计算2点之间的距离
- PHP计算2点经纬度之间的距离
- 根据经纬度计算地球2点之间的距离算法
- PHP计算2点经纬度之间的距离
- PHP计算2点经纬度之间的距离
- PHP计算2点经纬度之间的距离代码
- PHP计算2点经纬度之间的距离代码
- 计算2个坐标点之间的距离
- 计算地球上2点之间的距离
- 转载:高德地图计算2点之间的距离
- 计算两个坐标点之间的距离
- 计算两个坐标点之间的距离
- 根据2个经纬度点,计算这2个经纬度点之间的距离(通过经度纬度得到距离)
- 根据2个经纬度点,计算这2个经纬度点之间的距离(通过经度纬度得到距离)
- 根据2个经纬度点,计算这2个经纬度点之间的距离(通过经度纬度得到距离)
- Java 经纬度计算两个点的之间的距离
- 计算地图上两坐标点之间的距离
- java通过经纬度计算两坐标点之间的距离
- 使用Python2.7批量查询云窗IP
- 黑马程序员——ios开发基础之C语言之进制转换、位运算与内存管理
- Java中equals和==的区别
- 常见协议解析
- URLConnection
- 计算2点之间的距离
- 【leetcode】Largest Number --C++
- 黑马程序员——ios基础---练习:1
- "catalog" 与 "category" 的区别
- redis常用命令、常见错误、配置技巧
- 黑马程序员——TCP协议传输(下)
- SOA工程部署时报错:MDS-00054 (composite.xml does not exist)
- 黑马程序员——ios开发基础之C语言预处理命令与文件操作
- ‘tools.jar’ seems to be not in Android Studio classpath解决方法