IOS通过中心坐标以及圆弧坐标获取所有圆弧点坐标

话不多说,先上代码

CLLocationCoordinate2D centerCoord;

CLLocationCoordinate2D arcCoord;

//转为Map平面坐标

MKMapPoint centerPoint = MKMapPointForCoordinate(centerCoord);

MKMapPoint currentPoint = MKMapPointForCoordinate(arcCoord);

//计算平面距离

double pointDistance = sqrt(pow(currentPoint.x-centerPoint.x, 2)+pow(currentPoint.y-centerPoint.y, 2));

for (int I = 1 ; i <= 360; I++){

double x = pointDistance*cos(i*M_PI/180);

double y = pointDistance*sin(i*M_PI/180);

//转为经纬度

CLLocationCoordinate2D coord = MKCoordinateForMapPoint(MKMapPointMake(centerPoint.x+x, centerPoint.y+y));

}

思路:简单的说,利用mapkit里的mkmappoint巧妙的避免了经纬度的GIS计算,使用平面坐标计算得到mkmappoint类型的结果,再利用API转为经纬度结构体。

你可能感兴趣的:(IOS通过中心坐标以及圆弧坐标获取所有圆弧点坐标)